Remove snake_case.

This commit is contained in:
Brian Cao 2022-12-26 17:36:48 -08:00
parent e1f99a7d01
commit a91386434d
21 changed files with 86 additions and 100 deletions

View file

@ -10,9 +10,9 @@ export interface WebsiteEventDataRequestQuery {
}
export interface WebsiteEventDataRequestBody {
start_at: string;
end_at: string;
event_name: string;
startAt: string;
endAt: string;
eventName: string;
columns: { [key: string]: 'count' | 'max' | 'min' | 'avg' | 'sum' };
filters?: { [key: string]: any };
}
@ -34,10 +34,10 @@ export default async (
return unauthorized(res);
}
const { start_at, end_at, event_name: eventName, columns, filters } = req.body;
const { startAt, endAt, event_name: eventName, columns, filters } = req.body;
const startDate = new Date(+start_at);
const endDate = new Date(+end_at);
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
const events = await getEventData(websiteId, {
startDate,

View file

@ -10,12 +10,12 @@ const unitTypes = ['year', 'month', 'hour', 'day'];
export interface WebsiteEventsRequestQuery {
id: string;
start_at: string;
end_at: string;
startAt: string;
endAt: string;
unit: string;
tz: string;
url: string;
event_name: string;
eventName: string;
}
export default async (
@ -28,7 +28,7 @@ export default async (
const {
user: { id: userId },
} = req.auth;
const { id: websiteId, start_at, end_at, unit, tz, url, event_name } = req.query;
const { id: websiteId, startAt, endAt, unit, tz, url, eventName } = req.query;
if (req.method === 'GET') {
if (canViewWebsite(userId, websiteId)) {
@ -38,8 +38,8 @@ export default async (
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
return badRequest(res);
}
const startDate = new Date(+start_at);
const endDate = new Date(+end_at);
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
const events = await getEventMetrics(websiteId, {
startDate,
@ -48,7 +48,7 @@ export default async (
unit,
filters: {
url,
eventName: event_name,
eventName,
},
});

View file

@ -38,8 +38,8 @@ function getColumn(type) {
export interface WebsiteMetricsRequestQuery {
id: string;
type: string;
start_at: number;
end_at: number;
startAt: number;
endAt: number;
url: string;
referrer: string;
os: string;
@ -61,8 +61,8 @@ export default async (
const {
id: websiteId,
type,
start_at,
end_at,
startAt,
endAt,
url,
referrer,
os,
@ -76,8 +76,8 @@ export default async (
return unauthorized(res);
}
const startDate = new Date(+start_at);
const endDate = new Date(+end_at);
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
if (sessionColumns.includes(type)) {
let data = await getSessionMetrics(websiteId, {

View file

@ -11,8 +11,8 @@ const unitTypes = ['year', 'month', 'hour', 'day'];
export interface WebsitePageviewRequestQuery {
id: string;
websiteId: string;
start_at: number;
end_at: number;
startAt: number;
endAt: number;
unit: string;
tz: string;
url?: string;
@ -35,8 +35,8 @@ export default async (
} = req.auth;
const {
id: websiteId,
start_at,
end_at,
startAt,
endAt,
unit,
tz,
url,
@ -52,8 +52,8 @@ export default async (
return unauthorized(res);
}
const startDate = new Date(+start_at);
const endDate = new Date(+end_at);
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
return badRequest(res);

View file

@ -9,8 +9,8 @@ import { getWebsiteStats } from 'queries';
export interface WebsiteStatsRequestQuery {
id: string;
type: string;
start_at: number;
end_at: number;
startAt: number;
endAt: number;
url: string;
referrer: string;
os: string;
@ -29,29 +29,19 @@ export default async (
const {
user: { id: userId },
} = req.auth;
const {
id: websiteId,
start_at,
end_at,
url,
referrer,
os,
browser,
device,
country,
} = req.query;
const { id: websiteId, startAt, endAt, url, referrer, os, browser, device, country } = req.query;
if (req.method === 'GET') {
if (!(await canViewWebsite(userId, websiteId))) {
return unauthorized(res);
}
const startDate = new Date(+start_at);
const endDate = new Date(+end_at);
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
const distance = end_at - start_at;
const prevStartDate = new Date(+start_at - distance);
const prevEndDate = new Date(+end_at - distance);
const distance = endAt - startAt;
const prevStartDate = new Date(+startAt - distance);
const prevEndDate = new Date(+endAt - distance);
const metrics = await getWebsiteStats(websiteId, {
startDate,