mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Details page.
This commit is contained in:
parent
5b45301178
commit
ac2612924e
12 changed files with 312 additions and 10 deletions
18
lib/db.js
18
lib/db.js
|
|
@ -154,6 +154,24 @@ export async function getPageviews(website_id, start_at, end_at) {
|
|||
);
|
||||
}
|
||||
|
||||
export async function getRankings(website_id, start_at, end_at, type, table) {
|
||||
return runQuery(
|
||||
prisma.queryRaw(
|
||||
`
|
||||
select distinct "${type}" x, count(*) y
|
||||
from "${table}"
|
||||
where website_id=$1
|
||||
and created_at between $2 and $3
|
||||
group by 1
|
||||
order by 2 desc
|
||||
`,
|
||||
website_id,
|
||||
start_at,
|
||||
end_at,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function getPageviewData(
|
||||
website_id,
|
||||
start_at,
|
||||
|
|
|
|||
|
|
@ -24,10 +24,6 @@ export function formatTime(val) {
|
|||
}
|
||||
|
||||
export function formatShortTime(val, formats = ['m', 's'], space = '') {
|
||||
if (val <= 0) {
|
||||
return `0${formats[formats.length - 1]}`;
|
||||
}
|
||||
|
||||
const { days, hours, minutes, seconds, ms } = parseTime(val);
|
||||
let t = '';
|
||||
|
||||
|
|
@ -37,5 +33,9 @@ export function formatShortTime(val, formats = ['m', 's'], space = '') {
|
|||
if (seconds > 0 && formats.indexOf('s') !== -1) t += `${seconds}s${space}`;
|
||||
if (ms > 0 && formats.indexOf('ms') !== -1) t += `${ms}ms`;
|
||||
|
||||
if (!t) {
|
||||
return `0${formats[formats.length - 1]}`;
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue