mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
Merge pull request #1714 from umami-software/feat/um-136-camel-case
Remove snake_case.
This commit is contained in:
commit
677566b5f3
@ -109,8 +109,8 @@ export default function EventDataForm({ websiteId, onClose, className }) {
|
|||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
const params = {
|
const params = {
|
||||||
website_id: websiteId,
|
website_id: websiteId,
|
||||||
start_at: +startDate,
|
startAt: +startDate,
|
||||||
end_at: +endDate,
|
endAt: +endDate,
|
||||||
timezone,
|
timezone,
|
||||||
columns,
|
columns,
|
||||||
filters,
|
filters,
|
||||||
|
@ -21,7 +21,7 @@ export default function UserPasswordForm({ onSave, userId }) {
|
|||||||
const payload = isCurrentUser
|
const payload = isCurrentUser
|
||||||
? data
|
? data
|
||||||
: {
|
: {
|
||||||
password: data.new_password,
|
password: data.newPassword,
|
||||||
};
|
};
|
||||||
|
|
||||||
mutate(payload, {
|
mutate(payload, {
|
||||||
@ -33,7 +33,7 @@ export default function UserPasswordForm({ onSave, userId }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const samePassword = value => {
|
const samePassword = value => {
|
||||||
if (value !== ref?.current?.getValues('new_password')) {
|
if (value !== ref?.current?.getValues('newPassword')) {
|
||||||
return "Passwords don't match";
|
return "Passwords don't match";
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -42,16 +42,12 @@ export default function UserPasswordForm({ onSave, userId }) {
|
|||||||
return (
|
return (
|
||||||
<Form ref={ref} className={styles.form} onSubmit={handleSubmit} error={error}>
|
<Form ref={ref} className={styles.form} onSubmit={handleSubmit} error={error}>
|
||||||
{isCurrentUser && (
|
{isCurrentUser && (
|
||||||
<FormInput
|
<FormInput name="currentPassword" label="Current password" rules={{ required: 'Required' }}>
|
||||||
name="current_password"
|
|
||||||
label="Current password"
|
|
||||||
rules={{ required: 'Required' }}
|
|
||||||
>
|
|
||||||
<PasswordField autoComplete="off" />
|
<PasswordField autoComplete="off" />
|
||||||
</FormInput>
|
</FormInput>
|
||||||
)}
|
)}
|
||||||
<FormInput
|
<FormInput
|
||||||
name="new_password"
|
name="newPassword"
|
||||||
label="New password"
|
label="New password"
|
||||||
rules={{
|
rules={{
|
||||||
required: 'Required',
|
required: 'Required',
|
||||||
@ -61,7 +57,7 @@ export default function UserPasswordForm({ onSave, userId }) {
|
|||||||
<PasswordField autoComplete="off" />
|
<PasswordField autoComplete="off" />
|
||||||
</FormInput>
|
</FormInput>
|
||||||
<FormInput
|
<FormInput
|
||||||
name="confirm_password"
|
name="confirmPassword"
|
||||||
label="Confirm password"
|
label="Confirm password"
|
||||||
rules={{
|
rules={{
|
||||||
required: 'Required',
|
required: 'Required',
|
||||||
|
@ -19,12 +19,12 @@ export default function EventsChart({ websiteId, className, token }) {
|
|||||||
`/websites/${websiteId}/events`,
|
`/websites/${websiteId}/events`,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
start_at: +startDate,
|
startAt: +startDate,
|
||||||
end_at: +endDate,
|
endAt: +endDate,
|
||||||
unit,
|
unit,
|
||||||
tz: timezone,
|
tz: timezone,
|
||||||
url,
|
url,
|
||||||
event_name: eventName,
|
eventName,
|
||||||
token,
|
token,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -22,8 +22,8 @@ export default function MetricsBar({ websiteId, className }) {
|
|||||||
`/websites/${websiteId}/stats`,
|
`/websites/${websiteId}/stats`,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
start_at: +startDate,
|
startAt: +startDate,
|
||||||
end_at: +endDate,
|
endAt: +endDate,
|
||||||
url,
|
url,
|
||||||
referrer,
|
referrer,
|
||||||
os,
|
os,
|
||||||
|
@ -42,8 +42,8 @@ export default function MetricsTable({
|
|||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
type,
|
type,
|
||||||
start_at: +startDate,
|
startAt: +startDate,
|
||||||
end_at: +endDate,
|
endAt: +endDate,
|
||||||
url,
|
url,
|
||||||
referrer,
|
referrer,
|
||||||
os,
|
os,
|
||||||
|
@ -37,8 +37,8 @@ export default function WebsiteChart({
|
|||||||
`/websites/${websiteId}/pageviews`,
|
`/websites/${websiteId}/pageviews`,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
start_at: +startDate,
|
startAt: +startDate,
|
||||||
end_at: +endDate,
|
endAt: +endDate,
|
||||||
unit,
|
unit,
|
||||||
tz: timezone,
|
tz: timezone,
|
||||||
url,
|
url,
|
||||||
|
@ -35,7 +35,7 @@ export default function RealtimeDashboard() {
|
|||||||
const [websiteId, setWebsiteId] = useState(null);
|
const [websiteId, setWebsiteId] = useState(null);
|
||||||
const { data: init, loading } = useFetch('/realtime/init');
|
const { data: init, loading } = useFetch('/realtime/init');
|
||||||
const { data: updates } = useFetch('/realtime/update', {
|
const { data: updates } = useFetch('/realtime/update', {
|
||||||
params: { start_at: data?.timestamp },
|
params: { startAt: data?.timestamp },
|
||||||
disabled: !init?.websites?.length || !data,
|
disabled: !init?.websites?.length || !data,
|
||||||
interval: REALTIME_INTERVAL,
|
interval: REALTIME_INTERVAL,
|
||||||
headers: { [SHARE_TOKEN_HEADER]: init?.token },
|
headers: { [SHARE_TOKEN_HEADER]: init?.token },
|
||||||
|
@ -64,8 +64,8 @@ function getCommaSeparatedStringFormat(data) {
|
|||||||
return data.map(a => `'${a}'`).join(',') || '';
|
return data.map(a => `'${a}'`).join(',') || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBetweenDates(field, start_at, end_at) {
|
function getBetweenDates(field, startAt, endAt) {
|
||||||
return `${field} between ${getDateFormat(start_at)} and ${getDateFormat(end_at)}`;
|
return `${field} between ${getDateFormat(startAt)} and ${getDateFormat(endAt)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJsonField(column, property) {
|
function getJsonField(column, property) {
|
||||||
@ -120,7 +120,7 @@ function getFilterQuery(filters = {}, params = []) {
|
|||||||
case 'browser':
|
case 'browser':
|
||||||
case 'device':
|
case 'device':
|
||||||
case 'country':
|
case 'country':
|
||||||
case 'event_name':
|
case 'eventName':
|
||||||
arr.push(`and ${key}=$${params.length + 1}`);
|
arr.push(`and ${key}=$${params.length + 1}`);
|
||||||
params.push(decodeURIComponent(filter));
|
params.push(decodeURIComponent(filter));
|
||||||
break;
|
break;
|
||||||
@ -147,18 +147,18 @@ function getFilterQuery(filters = {}, params = []) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseFilters(filters = {}, params = []) {
|
function parseFilters(filters = {}, params = []) {
|
||||||
const { domain, url, event_url, referrer, os, browser, device, country, event_name, query } =
|
const { domain, url, event_url, referrer, os, browser, device, country, eventName, query } =
|
||||||
filters;
|
filters;
|
||||||
|
|
||||||
const pageviewFilters = { domain, url, referrer, query };
|
const pageviewFilters = { domain, url, referrer, query };
|
||||||
const sessionFilters = { os, browser, device, country };
|
const sessionFilters = { os, browser, device, country };
|
||||||
const eventFilters = { url: event_url, event_name };
|
const eventFilters = { url: event_url, eventName };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pageviewFilters,
|
pageviewFilters,
|
||||||
sessionFilters,
|
sessionFilters,
|
||||||
eventFilters,
|
eventFilters,
|
||||||
event: { event_name },
|
event: { eventName },
|
||||||
filterQuery: getFilterQuery(filters, params),
|
filterQuery: getFilterQuery(filters, params),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ function getFilterQuery(filters = {}, params = []): string {
|
|||||||
case 'browser':
|
case 'browser':
|
||||||
case 'device':
|
case 'device':
|
||||||
case 'country':
|
case 'country':
|
||||||
case 'event_name':
|
case 'eventName':
|
||||||
arr.push(`and ${key}=$${params.length + 1}`);
|
arr.push(`and ${key}=$${params.length + 1}`);
|
||||||
params.push(decodeURIComponent(filter));
|
params.push(decodeURIComponent(filter));
|
||||||
break;
|
break;
|
||||||
@ -187,18 +187,18 @@ function parseFilters(
|
|||||||
params = [],
|
params = [],
|
||||||
sessionKey = 'session_id',
|
sessionKey = 'session_id',
|
||||||
) {
|
) {
|
||||||
const { domain, url, event_url, referrer, os, browser, device, country, event_name, query } =
|
const { domain, url, event_url, referrer, os, browser, device, country, eventName, query } =
|
||||||
filters;
|
filters;
|
||||||
|
|
||||||
const pageviewFilters = { domain, url, referrer, query };
|
const pageviewFilters = { domain, url, referrer, query };
|
||||||
const sessionFilters = { os, browser, device, country };
|
const sessionFilters = { os, browser, device, country };
|
||||||
const eventFilters = { url: event_url, event_name };
|
const eventFilters = { url: event_url, eventName };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pageviewFilters,
|
pageviewFilters,
|
||||||
sessionFilters,
|
sessionFilters,
|
||||||
eventFilters,
|
eventFilters,
|
||||||
event: { event_name },
|
event: { eventName },
|
||||||
joinSession:
|
joinSession:
|
||||||
os || browser || device || country
|
os || browser || device || country
|
||||||
? `inner join session on ${sessionKey} = session.${sessionKey}`
|
? `inner join session on ${sessionKey} = session.${sessionKey}`
|
||||||
|
@ -31,7 +31,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||||||
|
|
||||||
const { type, payload } = getJsonBody(req);
|
const { type, payload } = getJsonBody(req);
|
||||||
|
|
||||||
const { referrer, event_name: eventName, event_data: eventData } = payload;
|
const { referrer, eventName, event_data: eventData } = payload;
|
||||||
let { url } = payload;
|
let { url } = payload;
|
||||||
|
|
||||||
// Validate eventData is JSON
|
// Validate eventData is JSON
|
||||||
|
@ -8,7 +8,7 @@ import { NextApiResponse } from 'next';
|
|||||||
import { RealtimeUpdate } from 'lib/types';
|
import { RealtimeUpdate } from 'lib/types';
|
||||||
|
|
||||||
export interface InitUpdateRequestQuery {
|
export interface InitUpdateRequestQuery {
|
||||||
start_at: string;
|
startAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (
|
export default async (
|
||||||
@ -18,7 +18,7 @@ export default async (
|
|||||||
await useAuth(req, res);
|
await useAuth(req, res);
|
||||||
|
|
||||||
if (req.method === 'GET') {
|
if (req.method === 'GET') {
|
||||||
const { start_at } = req.query;
|
const { startAt } = req.query;
|
||||||
|
|
||||||
const token = req.headers[SHARE_TOKEN_HEADER];
|
const token = req.headers[SHARE_TOKEN_HEADER];
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ export default async (
|
|||||||
|
|
||||||
const { websites } = parseToken(token, secret());
|
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);
|
return ok(res, data);
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ export interface TeamUserRequestQuery {
|
|||||||
|
|
||||||
export interface TeamUserRequestBody {
|
export interface TeamUserRequestBody {
|
||||||
email: string;
|
email: string;
|
||||||
role_id: string;
|
roleId: string;
|
||||||
team_user_id?: string;
|
teamUserId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (
|
export default async (
|
||||||
@ -41,7 +41,7 @@ export default async (
|
|||||||
return unauthorized(res, 'You must be the owner of this team.');
|
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
|
// Check for User
|
||||||
const user = await getUser({ username: email });
|
const user = await getUser({ username: email });
|
||||||
@ -59,9 +59,9 @@ export default async (
|
|||||||
if (await canUpdateTeam(userId, teamId)) {
|
if (await canUpdateTeam(userId, teamId)) {
|
||||||
return unauthorized(res, 'You must be the owner of this team.');
|
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);
|
return ok(res);
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ export interface UserPasswordRequestQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPasswordRequestBody {
|
export interface UserPasswordRequestBody {
|
||||||
current_password: string;
|
currentPassword: string;
|
||||||
new_password: string;
|
newPassword: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (
|
export default async (
|
||||||
@ -27,7 +27,7 @@ export default async (
|
|||||||
) => {
|
) => {
|
||||||
await useAuth(req, res);
|
await useAuth(req, res);
|
||||||
|
|
||||||
const { current_password, new_password } = req.body;
|
const { currentPassword, newPassword } = req.body;
|
||||||
const { id } = req.query;
|
const { id } = req.query;
|
||||||
const {
|
const {
|
||||||
user: { id: userId, isAdmin },
|
user: { id: userId, isAdmin },
|
||||||
@ -40,11 +40,11 @@ export default async (
|
|||||||
|
|
||||||
const user = await getUser({ id }, { includePassword: true });
|
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');
|
return badRequest(res, 'Current password is incorrect');
|
||||||
}
|
}
|
||||||
|
|
||||||
const password = hashPassword(new_password);
|
const password = hashPassword(newPassword);
|
||||||
|
|
||||||
const updated = await updateUser({ password }, { id });
|
const updated = await updateUser({ password }, { id });
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ export interface WebsiteEventDataRequestQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface WebsiteEventDataRequestBody {
|
export interface WebsiteEventDataRequestBody {
|
||||||
start_at: string;
|
startAt: string;
|
||||||
end_at: string;
|
endAt: string;
|
||||||
event_name: string;
|
eventName: string;
|
||||||
columns: { [key: string]: 'count' | 'max' | 'min' | 'avg' | 'sum' };
|
columns: { [key: string]: 'count' | 'max' | 'min' | 'avg' | 'sum' };
|
||||||
filters?: { [key: string]: any };
|
filters?: { [key: string]: any };
|
||||||
}
|
}
|
||||||
@ -34,10 +34,10 @@ export default async (
|
|||||||
return unauthorized(res);
|
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 startDate = new Date(+startAt);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+endAt);
|
||||||
|
|
||||||
const events = await getEventData(websiteId, {
|
const events = await getEventData(websiteId, {
|
||||||
startDate,
|
startDate,
|
||||||
|
@ -10,12 +10,12 @@ const unitTypes = ['year', 'month', 'hour', 'day'];
|
|||||||
|
|
||||||
export interface WebsiteEventsRequestQuery {
|
export interface WebsiteEventsRequestQuery {
|
||||||
id: string;
|
id: string;
|
||||||
start_at: string;
|
startAt: string;
|
||||||
end_at: string;
|
endAt: string;
|
||||||
unit: string;
|
unit: string;
|
||||||
tz: string;
|
tz: string;
|
||||||
url: string;
|
url: string;
|
||||||
event_name: string;
|
eventName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (
|
export default async (
|
||||||
@ -28,7 +28,7 @@ export default async (
|
|||||||
const {
|
const {
|
||||||
user: { id: userId },
|
user: { id: userId },
|
||||||
} = req.auth;
|
} = 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 (req.method === 'GET') {
|
||||||
if (canViewWebsite(userId, websiteId)) {
|
if (canViewWebsite(userId, websiteId)) {
|
||||||
@ -38,8 +38,8 @@ export default async (
|
|||||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
||||||
return badRequest(res);
|
return badRequest(res);
|
||||||
}
|
}
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+startAt);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+endAt);
|
||||||
|
|
||||||
const events = await getEventMetrics(websiteId, {
|
const events = await getEventMetrics(websiteId, {
|
||||||
startDate,
|
startDate,
|
||||||
@ -48,7 +48,7 @@ export default async (
|
|||||||
unit,
|
unit,
|
||||||
filters: {
|
filters: {
|
||||||
url,
|
url,
|
||||||
eventName: event_name,
|
eventName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ function getColumn(type) {
|
|||||||
export interface WebsiteMetricsRequestQuery {
|
export interface WebsiteMetricsRequestQuery {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
start_at: number;
|
startAt: number;
|
||||||
end_at: number;
|
endAt: number;
|
||||||
url: string;
|
url: string;
|
||||||
referrer: string;
|
referrer: string;
|
||||||
os: string;
|
os: string;
|
||||||
@ -61,8 +61,8 @@ export default async (
|
|||||||
const {
|
const {
|
||||||
id: websiteId,
|
id: websiteId,
|
||||||
type,
|
type,
|
||||||
start_at,
|
startAt,
|
||||||
end_at,
|
endAt,
|
||||||
url,
|
url,
|
||||||
referrer,
|
referrer,
|
||||||
os,
|
os,
|
||||||
@ -76,8 +76,8 @@ export default async (
|
|||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+startAt);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+endAt);
|
||||||
|
|
||||||
if (sessionColumns.includes(type)) {
|
if (sessionColumns.includes(type)) {
|
||||||
let data = await getSessionMetrics(websiteId, {
|
let data = await getSessionMetrics(websiteId, {
|
||||||
|
@ -11,8 +11,8 @@ const unitTypes = ['year', 'month', 'hour', 'day'];
|
|||||||
export interface WebsitePageviewRequestQuery {
|
export interface WebsitePageviewRequestQuery {
|
||||||
id: string;
|
id: string;
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
start_at: number;
|
startAt: number;
|
||||||
end_at: number;
|
endAt: number;
|
||||||
unit: string;
|
unit: string;
|
||||||
tz: string;
|
tz: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
@ -35,8 +35,8 @@ export default async (
|
|||||||
} = req.auth;
|
} = req.auth;
|
||||||
const {
|
const {
|
||||||
id: websiteId,
|
id: websiteId,
|
||||||
start_at,
|
startAt,
|
||||||
end_at,
|
endAt,
|
||||||
unit,
|
unit,
|
||||||
tz,
|
tz,
|
||||||
url,
|
url,
|
||||||
@ -52,8 +52,8 @@ export default async (
|
|||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+startAt);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+endAt);
|
||||||
|
|
||||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
||||||
return badRequest(res);
|
return badRequest(res);
|
||||||
|
@ -9,8 +9,8 @@ import { getWebsiteStats } from 'queries';
|
|||||||
export interface WebsiteStatsRequestQuery {
|
export interface WebsiteStatsRequestQuery {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
start_at: number;
|
startAt: number;
|
||||||
end_at: number;
|
endAt: number;
|
||||||
url: string;
|
url: string;
|
||||||
referrer: string;
|
referrer: string;
|
||||||
os: string;
|
os: string;
|
||||||
@ -29,29 +29,19 @@ export default async (
|
|||||||
const {
|
const {
|
||||||
user: { id: userId },
|
user: { id: userId },
|
||||||
} = req.auth;
|
} = req.auth;
|
||||||
const {
|
const { id: websiteId, startAt, endAt, url, referrer, os, browser, device, country } = req.query;
|
||||||
id: websiteId,
|
|
||||||
start_at,
|
|
||||||
end_at,
|
|
||||||
url,
|
|
||||||
referrer,
|
|
||||||
os,
|
|
||||||
browser,
|
|
||||||
device,
|
|
||||||
country,
|
|
||||||
} = req.query;
|
|
||||||
|
|
||||||
if (req.method === 'GET') {
|
if (req.method === 'GET') {
|
||||||
if (!(await canViewWebsite(userId, websiteId))) {
|
if (!(await canViewWebsite(userId, websiteId))) {
|
||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+startAt);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+endAt);
|
||||||
|
|
||||||
const distance = end_at - start_at;
|
const distance = endAt - startAt;
|
||||||
const prevStartDate = new Date(+start_at - distance);
|
const prevStartDate = new Date(+startAt - distance);
|
||||||
const prevEndDate = new Date(+end_at - distance);
|
const prevEndDate = new Date(+endAt - distance);
|
||||||
|
|
||||||
const metrics = await getWebsiteStats(websiteId, {
|
const metrics = await getWebsiteStats(websiteId, {
|
||||||
startDate,
|
startDate,
|
||||||
|
@ -9,20 +9,20 @@ export function getEvents(...args) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function relationalQuery(websites, start_at) {
|
function relationalQuery(websites, startAt) {
|
||||||
return prisma.client.event.findMany({
|
return prisma.client.event.findMany({
|
||||||
where: {
|
where: {
|
||||||
websiteId: {
|
websiteId: {
|
||||||
in: websites,
|
in: websites,
|
||||||
},
|
},
|
||||||
createdAt: {
|
createdAt: {
|
||||||
gte: start_at,
|
gte: startAt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickhouseQuery(websites, start_at) {
|
function clickhouseQuery(websites, startAt) {
|
||||||
const { rawQuery, getDateFormat, getCommaSeparatedStringFormat } = clickhouse;
|
const { rawQuery, getDateFormat, getCommaSeparatedStringFormat } = clickhouse;
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
@ -40,6 +40,6 @@ function clickhouseQuery(websites, start_at) {
|
|||||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||||
: '0 = 0'
|
: '0 = 0'
|
||||||
}
|
}
|
||||||
and created_at >= ${getDateFormat(start_at)}`,
|
and created_at >= ${getDateFormat(startAt)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,20 @@ export async function getPageviews(...args) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function relationalQuery(websites, start_at) {
|
async function relationalQuery(websites, startAt) {
|
||||||
return prisma.client.pageview.findMany({
|
return prisma.client.pageview.findMany({
|
||||||
where: {
|
where: {
|
||||||
websiteId: {
|
websiteId: {
|
||||||
in: websites,
|
in: websites,
|
||||||
},
|
},
|
||||||
createdAt: {
|
createdAt: {
|
||||||
gte: start_at,
|
gte: startAt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clickhouseQuery(websites, start_at) {
|
async function clickhouseQuery(websites, startAt) {
|
||||||
const { rawQuery, getCommaSeparatedStringFormat } = clickhouse;
|
const { rawQuery, getCommaSeparatedStringFormat } = clickhouse;
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
@ -38,6 +38,6 @@ async function clickhouseQuery(websites, start_at) {
|
|||||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||||
: '0 = 0'
|
: '0 = 0'
|
||||||
}
|
}
|
||||||
and created_at >= ${clickhouse.getDateFormat(start_at)}`,
|
and created_at >= ${clickhouse.getDateFormat(startAt)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ export async function getSessions(...args) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function relationalQuery(websites, start_at) {
|
async function relationalQuery(websites, startAt) {
|
||||||
return prisma.client.session.findMany({
|
return prisma.client.session.findMany({
|
||||||
where: {
|
where: {
|
||||||
...(websites && websites.length > 0
|
...(websites && websites.length > 0
|
||||||
@ -20,13 +20,13 @@ async function relationalQuery(websites, start_at) {
|
|||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
createdAt: {
|
createdAt: {
|
||||||
gte: start_at,
|
gte: startAt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clickhouseQuery(websites, start_at) {
|
async function clickhouseQuery(websites, startAt) {
|
||||||
const { rawQuery, getDateFormat, getCommaSeparatedStringFormat } = clickhouse;
|
const { rawQuery, getDateFormat, getCommaSeparatedStringFormat } = clickhouse;
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
@ -47,6 +47,6 @@ async function clickhouseQuery(websites, start_at) {
|
|||||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||||
: '0 = 0'
|
: '0 = 0'
|
||||||
}
|
}
|
||||||
and created_at >= ${getDateFormat(start_at)}`,
|
and created_at >= ${getDateFormat(startAt)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user