mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Update realtime chart.
This commit is contained in:
parent
e64a555652
commit
fdc92d087b
32 changed files with 240 additions and 58 deletions
|
|
@ -7,6 +7,7 @@ import {
|
|||
addYears,
|
||||
subHours,
|
||||
subDays,
|
||||
startOfMinute,
|
||||
startOfHour,
|
||||
startOfDay,
|
||||
startOfWeek,
|
||||
|
|
@ -17,6 +18,7 @@ import {
|
|||
endOfWeek,
|
||||
endOfMonth,
|
||||
endOfYear,
|
||||
differenceInMinutes,
|
||||
differenceInHours,
|
||||
differenceInCalendarDays,
|
||||
differenceInCalendarMonths,
|
||||
|
|
@ -114,6 +116,7 @@ export function getDateFromString(str) {
|
|||
}
|
||||
|
||||
const dateFuncs = {
|
||||
minute: [differenceInMinutes, addMinutes, startOfMinute],
|
||||
hour: [differenceInHours, addHours, startOfHour],
|
||||
day: [differenceInCalendarDays, addDays, startOfDay],
|
||||
month: [differenceInCalendarMonths, addMonths, startOfMonth],
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
12
lib/web.js
12
lib/web.js
|
|
@ -19,13 +19,17 @@ export const apiRequest = (method, url, body, headers) =>
|
|||
return res.text().then(data => ({ ok: res.ok, status: res.status, res: res, data }));
|
||||
});
|
||||
|
||||
export const get = (url, params) => apiRequest('get', `${url}${getQueryString(params)}`);
|
||||
export const get = (url, params, headers) =>
|
||||
apiRequest('get', `${url}${getQueryString(params)}`, undefined, headers);
|
||||
|
||||
export const del = (url, params) => apiRequest('delete', `${url}${getQueryString(params)}`);
|
||||
export const del = (url, params, headers) =>
|
||||
apiRequest('delete', `${url}${getQueryString(params)}`, undefined, headers);
|
||||
|
||||
export const post = (url, params) => apiRequest('post', url, JSON.stringify(params));
|
||||
export const post = (url, params, headers) =>
|
||||
apiRequest('post', url, JSON.stringify(params), headers);
|
||||
|
||||
export const put = (url, params) => apiRequest('put', url, JSON.stringify(params));
|
||||
export const put = (url, params, headers) =>
|
||||
apiRequest('put', url, JSON.stringify(params), headers);
|
||||
|
||||
export const hook = (_this, method, callback) => {
|
||||
const orig = _this[method];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue