mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Formatting.
This commit is contained in:
parent
200e9b8bfa
commit
0cc289b3cd
@ -103,6 +103,7 @@ async function rawQuery(sql: string, data: object): Promise<any> {
|
|||||||
if (db !== POSTGRESQL && db !== MYSQL) {
|
if (db !== POSTGRESQL && db !== MYSQL) {
|
||||||
return Promise.reject(new Error('Unknown database.'));
|
return Promise.reject(new Error('Unknown database.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = sql?.replaceAll(/\{\{\s*(\w+)(::\w+)?\s*}}/g, (...args) => {
|
const query = sql?.replaceAll(/\{\{\s*(\w+)(::\w+)?\s*}}/g, (...args) => {
|
||||||
const [, name, type] = args;
|
const [, name, type] = args;
|
||||||
params.push(data[name]);
|
params.push(data[name]);
|
||||||
|
@ -78,15 +78,18 @@ async function relationalQuery(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`WITH level1 AS (
|
`
|
||||||
|
WITH level1 AS (
|
||||||
select distinct session_id, created_at
|
select distinct session_id, created_at
|
||||||
from website_event
|
from website_event
|
||||||
where website_id = {{websiteId::uuid}}
|
where website_id = {{websiteId::uuid}}
|
||||||
and created_at between {{startDate}} and {{endDate}}
|
and created_at between {{startDate}} and {{endDate}}
|
||||||
and url_path = {{0}})
|
and url_path = {{0}}
|
||||||
|
)
|
||||||
${levelQuery}
|
${levelQuery}
|
||||||
${sumQuery}
|
${sumQuery}
|
||||||
ORDER BY level;`,
|
ORDER BY level;
|
||||||
|
`,
|
||||||
{
|
{
|
||||||
websiteId,
|
websiteId,
|
||||||
startDate,
|
startDate,
|
||||||
@ -97,7 +100,7 @@ async function relationalQuery(
|
|||||||
return urls.map((a, i) => ({
|
return urls.map((a, i) => ({
|
||||||
x: a,
|
x: a,
|
||||||
y: results[i]?.count || 0,
|
y: results[i]?.count || 0,
|
||||||
z: (1 - (Number(results[i]?.count) * 1.0) / Number(results[i - 1]?.count)) * 100 || 0, // drop off
|
z: (1 - Number(results[i]?.count) / Number(results[i - 1]?.count)) * 100 || 0, // drop off
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -173,17 +176,20 @@ async function clickhouseQuery(
|
|||||||
select distinct session_id, url_path, referrer_path, created_at
|
select distinct session_id, url_path, referrer_path, created_at
|
||||||
from umami.website_event
|
from umami.website_event
|
||||||
where url_path in (${urlFilterQuery})
|
where url_path in (${urlFilterQuery})
|
||||||
and website_id = {websiteId:UUID}
|
and website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
), level1 AS (
|
),
|
||||||
|
level1 AS (
|
||||||
select *
|
select *
|
||||||
from level0
|
from level0
|
||||||
where url_path = {url0:String})
|
where url_path = {url0:String}
|
||||||
|
)
|
||||||
${levelQuery}
|
${levelQuery}
|
||||||
select *
|
select *
|
||||||
from (
|
from (
|
||||||
${sumQuery}
|
${sumQuery}
|
||||||
) ORDER BY level;`,
|
) ORDER BY level;
|
||||||
|
`,
|
||||||
{
|
{
|
||||||
websiteId,
|
websiteId,
|
||||||
startDate,
|
startDate,
|
||||||
@ -194,7 +200,7 @@ async function clickhouseQuery(
|
|||||||
return urls.map((a, i) => ({
|
return urls.map((a, i) => ({
|
||||||
x: a,
|
x: a,
|
||||||
y: results[i]?.count || 0,
|
y: results[i]?.count || 0,
|
||||||
z: (1 - (Number(results[i]?.count) * 1.0) / Number(results[i - 1]?.count)) * 100 || 0, // drop off
|
z: (1 - Number(results[i]?.count) / Number(results[i - 1]?.count)) * 100 || 0, // drop off
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user