mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
Remove snake_case.
This commit is contained in:
parent
e1f99a7d01
commit
a91386434d
21 changed files with 86 additions and 100 deletions
|
|
@ -31,7 +31,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
|
||||
const { type, payload } = getJsonBody(req);
|
||||
|
||||
const { referrer, event_name: eventName, event_data: eventData } = payload;
|
||||
const { referrer, eventName, event_data: eventData } = payload;
|
||||
let { url } = payload;
|
||||
|
||||
// Validate eventData is JSON
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { NextApiResponse } from 'next';
|
|||
import { RealtimeUpdate } from 'lib/types';
|
||||
|
||||
export interface InitUpdateRequestQuery {
|
||||
start_at: string;
|
||||
startAt: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
|
|
@ -18,7 +18,7 @@ export default async (
|
|||
await useAuth(req, res);
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { start_at } = req.query;
|
||||
const { startAt } = req.query;
|
||||
|
||||
const token = req.headers[SHARE_TOKEN_HEADER];
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ export default async (
|
|||
|
||||
const { websites } = parseToken(token, secret());
|
||||
|
||||
const data = await getRealtimeData(websites, new Date(+start_at));
|
||||
const data = await getRealtimeData(websites, new Date(+startAt));
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ export interface TeamUserRequestQuery {
|
|||
|
||||
export interface TeamUserRequestBody {
|
||||
email: string;
|
||||
role_id: string;
|
||||
team_user_id?: string;
|
||||
roleId: string;
|
||||
teamUserId?: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
|
|
@ -41,7 +41,7 @@ export default async (
|
|||
return unauthorized(res, 'You must be the owner of this team.');
|
||||
}
|
||||
|
||||
const { email, role_id: roleId } = req.body;
|
||||
const { email, roleId: roleId } = req.body;
|
||||
|
||||
// Check for User
|
||||
const user = await getUser({ username: email });
|
||||
|
|
@ -59,9 +59,9 @@ export default async (
|
|||
if (await canUpdateTeam(userId, teamId)) {
|
||||
return unauthorized(res, 'You must be the owner of this team.');
|
||||
}
|
||||
const { team_user_id } = req.body;
|
||||
const { teamUserId } = req.body;
|
||||
|
||||
await deleteTeamUser(team_user_id);
|
||||
await deleteTeamUser(teamUserId);
|
||||
|
||||
return ok(res);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ export interface UserPasswordRequestQuery {
|
|||
}
|
||||
|
||||
export interface UserPasswordRequestBody {
|
||||
current_password: string;
|
||||
new_password: string;
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
|
|
@ -27,7 +27,7 @@ export default async (
|
|||
) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { current_password, new_password } = req.body;
|
||||
const { currentPassword, newPassword } = req.body;
|
||||
const { id } = req.query;
|
||||
const {
|
||||
user: { id: userId, isAdmin },
|
||||
|
|
@ -40,11 +40,11 @@ export default async (
|
|||
|
||||
const user = await getUser({ id }, { includePassword: true });
|
||||
|
||||
if (!checkPassword(current_password, user.password)) {
|
||||
if (!checkPassword(currentPassword, user.password)) {
|
||||
return badRequest(res, 'Current password is incorrect');
|
||||
}
|
||||
|
||||
const password = hashPassword(new_password);
|
||||
const password = hashPassword(newPassword);
|
||||
|
||||
const updated = await updateUser({ password }, { id });
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue