mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
All queries should use runQuery.
This commit is contained in:
parent
a3e920d944
commit
f17be19110
@ -252,7 +252,8 @@ export function getMetrics(website_id, start_at, end_at) {
|
|||||||
const db = getDatabase();
|
const db = getDatabase();
|
||||||
|
|
||||||
if (db === POSTGRESQL) {
|
if (db === POSTGRESQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select sum(t.c) as "pageviews",
|
select sum(t.c) as "pageviews",
|
||||||
count(distinct t.session_id) as "uniques",
|
count(distinct t.session_id) as "uniques",
|
||||||
@ -272,11 +273,13 @@ export function getMetrics(website_id, start_at, end_at) {
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db === MYSQL) {
|
if (db === MYSQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select sum(t.c) as "pageviews",
|
select sum(t.c) as "pageviews",
|
||||||
count(distinct t.session_id) as "uniques",
|
count(distinct t.session_id) as "uniques",
|
||||||
@ -296,6 +299,7 @@ export function getMetrics(website_id, start_at, end_at) {
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +317,8 @@ export function getPageviews(
|
|||||||
const db = getDatabase();
|
const db = getDatabase();
|
||||||
|
|
||||||
if (db === POSTGRESQL) {
|
if (db === POSTGRESQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select ${getDateQuery(db, 'created_at', unit, timezone)} t,
|
select ${getDateQuery(db, 'created_at', unit, timezone)} t,
|
||||||
count(${count}) y
|
count(${count}) y
|
||||||
@ -326,11 +331,13 @@ export function getPageviews(
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db === MYSQL) {
|
if (db === MYSQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select ${getDateQuery(db, 'created_at', unit, timezone)} t,
|
select ${getDateQuery(db, 'created_at', unit, timezone)} t,
|
||||||
count(${count}) y
|
count(${count}) y
|
||||||
@ -343,6 +350,7 @@ export function getPageviews(
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +363,8 @@ export function getRankings(website_id, start_at, end_at, type, table, domain) {
|
|||||||
const filter = domain ? `and ${type} not like '%${domain}%'` : '';
|
const filter = domain ? `and ${type} not like '%${domain}%'` : '';
|
||||||
|
|
||||||
if (db === POSTGRESQL) {
|
if (db === POSTGRESQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select distinct ${type} x, count(*) y
|
select distinct ${type} x, count(*) y
|
||||||
from ${table}
|
from ${table}
|
||||||
@ -368,11 +377,13 @@ export function getRankings(website_id, start_at, end_at, type, table, domain) {
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db === MYSQL) {
|
if (db === MYSQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select distinct ${type} x, count(*) y
|
select distinct ${type} x, count(*) y
|
||||||
from ${table}
|
from ${table}
|
||||||
@ -385,6 +396,7 @@ export function getRankings(website_id, start_at, end_at, type, table, domain) {
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +408,8 @@ export function getActiveVisitors(website_id) {
|
|||||||
const date = subMinutes(new Date(), 5);
|
const date = subMinutes(new Date(), 5);
|
||||||
|
|
||||||
if (db === POSTGRESQL) {
|
if (db === POSTGRESQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select count(distinct session_id) x
|
select count(distinct session_id) x
|
||||||
from pageview
|
from pageview
|
||||||
@ -405,11 +418,13 @@ export function getActiveVisitors(website_id) {
|
|||||||
`,
|
`,
|
||||||
website_id,
|
website_id,
|
||||||
date,
|
date,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db === MYSQL) {
|
if (db === MYSQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select count(distinct session_id) x
|
select count(distinct session_id) x
|
||||||
from pageview
|
from pageview
|
||||||
@ -418,6 +433,7 @@ export function getActiveVisitors(website_id) {
|
|||||||
`,
|
`,
|
||||||
website_id,
|
website_id,
|
||||||
date,
|
date,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +444,8 @@ export function getEvents(website_id, start_at, end_at, timezone = 'utc', unit =
|
|||||||
const db = getDatabase();
|
const db = getDatabase();
|
||||||
|
|
||||||
if (db === POSTGRESQL) {
|
if (db === POSTGRESQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
event_value x,
|
event_value x,
|
||||||
@ -443,11 +460,13 @@ export function getEvents(website_id, start_at, end_at, timezone = 'utc', unit =
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db === MYSQL) {
|
if (db === MYSQL) {
|
||||||
return prisma.$queryRaw(
|
return runQuery(
|
||||||
|
prisma.$queryRaw(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
event_value x,
|
event_value x,
|
||||||
@ -462,6 +481,7 @@ export function getEvents(website_id, start_at, end_at, timezone = 'utc', unit =
|
|||||||
website_id,
|
website_id,
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user