Update realtime chart.

This commit is contained in:
Mike Cao 2020-10-08 23:26:05 -07:00
parent e64a555652
commit fdc92d087b
32 changed files with 240 additions and 58 deletions

View file

@ -166,16 +166,6 @@ export async function createSession(website_id, data) {
);
}
export async function getSessionById(session_id) {
return runQuery(
prisma.session.findOne({
where: {
session_id,
},
}),
);
}
export async function getSessionByUuid(session_uuid) {
return runQuery(
prisma.session.findOne({
@ -285,6 +275,57 @@ export async function createAccount(data) {
);
}
export async function getSessions(websites, start_at) {
return runQuery(
prisma.session.findMany({
where: {
website: {
website_id: {
in: websites,
},
},
created_at: {
gte: start_at,
},
},
}),
);
}
export async function getPageviews(websites, start_at) {
return runQuery(
prisma.pageview.findMany({
where: {
website: {
website_id: {
in: websites,
},
},
created_at: {
gte: start_at,
},
},
}),
);
}
export async function getEvents(websites, start_at) {
return runQuery(
prisma.event.findMany({
where: {
website: {
website_id: {
in: websites,
},
},
created_at: {
gte: start_at,
},
},
}),
);
}
export function getWebsiteStats(website_id, start_at, end_at, filters = {}) {
const params = [website_id, start_at, end_at];
const { url } = filters;
@ -425,7 +466,7 @@ export function getActiveVisitors(website_id) {
);
}
export function getEvents(
export function getEventMetrics(
website_id,
start_at,
end_at,