only use hourly table, remove daily table logic, fix updatechart undefined

This commit is contained in:
Francis Cao 2024-07-23 22:35:11 -07:00
parent 038ecdb592
commit 174b9e4376
10 changed files with 38 additions and 166 deletions

View file

@ -64,7 +64,7 @@ export default async (
await useAuth(req, res);
await useValidate(schema, req, res);
const { websiteId, type, limit, offset, search, unit } = req.query;
const { websiteId, type, limit, offset, search } = req.query;
if (req.method === 'GET') {
if (!(await canViewWebsite(req.auth, websiteId))) {
@ -89,7 +89,7 @@ export default async (
}
if (SESSION_COLUMNS.includes(type)) {
const data = await getSessionMetrics(websiteId, type, filters, limit, offset, unit as string);
const data = await getSessionMetrics(websiteId, type, filters, limit, offset);
if (type === 'language') {
const combined = {};
@ -111,14 +111,7 @@ export default async (
}
if (EVENT_COLUMNS.includes(type)) {
const data = await getPageviewMetrics(
websiteId,
type,
filters,
limit,
offset,
unit as string,
);
const data = await getPageviewMetrics(websiteId, type, filters, limit, offset);
return ok(res, data);
}

View file

@ -56,7 +56,7 @@ export default async (
await useAuth(req, res);
await useValidate(schema, req, res);
const { websiteId, compare, unit } = req.query;
const { websiteId, compare } = req.query;
if (req.method === 'GET') {
if (!(await canViewWebsite(req.auth, websiteId))) {
@ -72,13 +72,13 @@ export default async (
const filters = getRequestFilters(req);
const metrics = await getWebsiteStats(websiteId, unit as string, {
const metrics = await getWebsiteStats(websiteId, {
...filters,
startDate,
endDate,
});
const prevPeriod = await getWebsiteStats(websiteId, unit as string, {
const prevPeriod = await getWebsiteStats(websiteId, {
...filters,
startDate: compareStartDate,
endDate: compareEndDate,