fix get event metrics card and create it's own query

This commit is contained in:
Francis Cao 2025-07-21 10:49:48 -07:00
parent ab0826d91a
commit a81b144cd6
5 changed files with 157 additions and 55 deletions

View file

@ -15,7 +15,12 @@ import {
} from '@/lib/constants';
import { getRequestFilters, getRequestDateRange, parseRequest } from '@/lib/request';
import { json, unauthorized, badRequest } from '@/lib/response';
import { getPageviewMetrics, getSessionMetrics, getChannelMetrics } from '@/queries';
import {
getPageviewMetrics,
getSessionMetrics,
getEventMetrics,
getChannelMetrics,
} from '@/queries';
import { filterParams } from '@/lib/schema';
export async function GET(
@ -85,7 +90,13 @@ export async function GET(
}
if (EVENT_COLUMNS.includes(type)) {
const data = await getPageviewMetrics(websiteId, type, filters, limit, offset);
let data;
if (type === 'event') {
data = await getEventMetrics(websiteId, type, filters, limit, offset);
} else {
data = await getPageviewMetrics(websiteId, type, filters, limit, offset);
}
return json(data);
}