mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Auth and session middleware.
This commit is contained in:
parent
590a70c2ff
commit
d81ee3932d
14 changed files with 142 additions and 73 deletions
36
lib/db.js
36
lib/db.js
|
|
@ -32,6 +32,16 @@ export async function getWebsite(website_uuid) {
|
|||
);
|
||||
}
|
||||
|
||||
export async function getWebsites(user_id) {
|
||||
return runQuery(
|
||||
prisma.website.findMany({
|
||||
where: {
|
||||
user_id,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function createSession(website_id, data) {
|
||||
return runQuery(
|
||||
prisma.session.create({
|
||||
|
|
@ -126,3 +136,29 @@ export async function getPageviews(website_id, start_at, end_at) {
|
|||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function getPageviewData(
|
||||
website_id,
|
||||
start_at,
|
||||
end_at,
|
||||
timezone = 'utc',
|
||||
unit = 'day',
|
||||
count = '*',
|
||||
) {
|
||||
return runQuery(
|
||||
prisma.queryRaw(
|
||||
`
|
||||
select date_trunc('${unit}', created_at at time zone '${timezone}') t,
|
||||
count(${count}) y
|
||||
from pageview
|
||||
where website_id=$1
|
||||
and created_at between $2 and $3
|
||||
group by 1
|
||||
order by 1
|
||||
`,
|
||||
website_id,
|
||||
start_at,
|
||||
end_at,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue