add psql query for retention

This commit is contained in:
Francis Cao 2023-08-07 14:01:53 -07:00
parent ff5884237c
commit 13530c9cdc
5 changed files with 193 additions and 195 deletions

View file

@ -7,17 +7,12 @@ import { getRetention } from 'queries';
export interface RetentionRequestBody {
websiteId: string;
urls: string[];
window: number;
dateRange: {
startDate: string;
endDate: string;
};
window: string;
dateRange: { window; startDate: string; endDate: string };
}
export interface RetentionResponse {
urls: string[];
window: number;
window: string;
startAt: number;
endAt: number;
}
@ -32,7 +27,6 @@ export default async (
if (req.method === 'POST') {
const {
websiteId,
urls,
window,
dateRange: { startDate, endDate },
} = req.body;
@ -44,8 +38,7 @@ export default async (
const data = await getRetention(websiteId, {
startDate: new Date(startDate),
endDate: new Date(endDate),
urls,
windowMinutes: +window,
window: window,
});
return ok(res, data);