mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-01 12:29:35 +01:00
parent
a6a4cf9e9b
commit
edd679295c
@ -43,7 +43,7 @@ async function relationalQuery(
|
|||||||
): Promise<JourneyResult[]> {
|
): Promise<JourneyResult[]> {
|
||||||
const { startDate, endDate, steps, startStep, endStep } = filters;
|
const { startDate, endDate, steps, startStep, endStep } = filters;
|
||||||
const { rawQuery } = prisma;
|
const { rawQuery } = prisma;
|
||||||
const { sequenceQuery, startStepQuery, endStepQuery, finalSelectQuery, params } = getJourneyQuery(
|
const { sequenceQuery, startStepQuery, endStepQuery, params } = getJourneyQuery(
|
||||||
steps,
|
steps,
|
||||||
startStep,
|
startStep,
|
||||||
endStep,
|
endStep,
|
||||||
@ -57,14 +57,12 @@ async function relationalQuery(
|
|||||||
sequenceQuery: string;
|
sequenceQuery: string;
|
||||||
startStepQuery: string;
|
startStepQuery: string;
|
||||||
endStepQuery: string;
|
endStepQuery: string;
|
||||||
finalSelectQuery: string;
|
|
||||||
params: { [key: string]: string };
|
params: { [key: string]: string };
|
||||||
} {
|
} {
|
||||||
const params = {};
|
const params = {};
|
||||||
let sequenceQuery = '';
|
let sequenceQuery = '';
|
||||||
let startStepQuery = '';
|
let startStepQuery = '';
|
||||||
let endStepQuery = '';
|
let endStepQuery = '';
|
||||||
let finalSelectQuery = '';
|
|
||||||
|
|
||||||
// create sequence query
|
// create sequence query
|
||||||
let selectQuery = '';
|
let selectQuery = '';
|
||||||
@ -106,18 +104,10 @@ async function relationalQuery(
|
|||||||
params['endStep'] = endStep;
|
params['endStep'] = endStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create final select query
|
|
||||||
for (let i = 1; i < steps; i++) {
|
|
||||||
finalSelectQuery += `\nCASE WHEN e${i} IS NOT NULL and e${
|
|
||||||
i + 1
|
|
||||||
} IS NULL THEN 'dropped off' ELSE e${i + 1} END AS e${i + 1},`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sequenceQuery,
|
sequenceQuery,
|
||||||
startStepQuery,
|
startStepQuery,
|
||||||
endStepQuery,
|
endStepQuery,
|
||||||
finalSelectQuery,
|
|
||||||
params,
|
params,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -134,9 +124,7 @@ async function relationalQuery(
|
|||||||
where website_id = {{websiteId::uuid}}
|
where website_id = {{websiteId::uuid}}
|
||||||
and created_at between {{startDate}} and {{endDate}}),
|
and created_at between {{startDate}} and {{endDate}}),
|
||||||
${sequenceQuery}
|
${sequenceQuery}
|
||||||
select e1,
|
select *
|
||||||
${finalSelectQuery}
|
|
||||||
count
|
|
||||||
from sequences
|
from sequences
|
||||||
where 1 = 1
|
where 1 = 1
|
||||||
${startStepQuery}
|
${startStepQuery}
|
||||||
@ -165,7 +153,7 @@ async function clickhouseQuery(
|
|||||||
): Promise<JourneyResult[]> {
|
): Promise<JourneyResult[]> {
|
||||||
const { startDate, endDate, steps, startStep, endStep } = filters;
|
const { startDate, endDate, steps, startStep, endStep } = filters;
|
||||||
const { rawQuery } = clickhouse;
|
const { rawQuery } = clickhouse;
|
||||||
const { sequenceQuery, startStepQuery, endStepQuery, finalSelectQuery, params } = getJourneyQuery(
|
const { sequenceQuery, startStepQuery, endStepQuery, params } = getJourneyQuery(
|
||||||
steps,
|
steps,
|
||||||
startStep,
|
startStep,
|
||||||
endStep,
|
endStep,
|
||||||
@ -179,14 +167,12 @@ async function clickhouseQuery(
|
|||||||
sequenceQuery: string;
|
sequenceQuery: string;
|
||||||
startStepQuery: string;
|
startStepQuery: string;
|
||||||
endStepQuery: string;
|
endStepQuery: string;
|
||||||
finalSelectQuery: string;
|
|
||||||
params: { [key: string]: string };
|
params: { [key: string]: string };
|
||||||
} {
|
} {
|
||||||
const params = {};
|
const params = {};
|
||||||
let sequenceQuery = '';
|
let sequenceQuery = '';
|
||||||
let startStepQuery = '';
|
let startStepQuery = '';
|
||||||
let endStepQuery = '';
|
let endStepQuery = '';
|
||||||
let finalSelectQuery = '';
|
|
||||||
|
|
||||||
// create sequence query
|
// create sequence query
|
||||||
let selectQuery = '';
|
let selectQuery = '';
|
||||||
@ -221,25 +207,17 @@ async function clickhouseQuery(
|
|||||||
if (endStep) {
|
if (endStep) {
|
||||||
for (let i = 1; i < steps; i++) {
|
for (let i = 1; i < steps; i++) {
|
||||||
const startQuery = i === 1 ? 'and (' : '\nor ';
|
const startQuery = i === 1 ? 'and (' : '\nor ';
|
||||||
endStepQuery += `${startQuery}(e${i} = {endStep:String} and e${i + 1} = 'dropped off') `;
|
endStepQuery += `${startQuery}(e${i} = {endStep:String} and e${i + 1} is null) `;
|
||||||
}
|
}
|
||||||
endStepQuery += `\nor (e${steps} = {endStep:String}))`;
|
endStepQuery += `\nor (e${steps} = {endStep:String}))`;
|
||||||
|
|
||||||
params['endStep'] = endStep;
|
params['endStep'] = endStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create final select query
|
|
||||||
for (let i = 1; i < steps; i++) {
|
|
||||||
finalSelectQuery += `\nCASE WHEN e${i} IS NOT NULL and e${
|
|
||||||
i + 1
|
|
||||||
} IS NULL THEN 'dropped off' ELSE e${i + 1} END AS e${i + 1},`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sequenceQuery,
|
sequenceQuery,
|
||||||
startStepQuery,
|
startStepQuery,
|
||||||
endStepQuery,
|
endStepQuery,
|
||||||
finalSelectQuery,
|
|
||||||
params,
|
params,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -255,9 +233,7 @@ async function clickhouseQuery(
|
|||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}),
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}),
|
||||||
${sequenceQuery}
|
${sequenceQuery}
|
||||||
select e1,
|
select *
|
||||||
${finalSelectQuery}
|
|
||||||
count
|
|
||||||
from sequences
|
from sequences
|
||||||
where 1 = 1
|
where 1 = 1
|
||||||
${startStepQuery}
|
${startStepQuery}
|
||||||
|
Loading…
Reference in New Issue
Block a user