add dropoff percentages to funnel report
This commit is contained in:
@@ -48,11 +48,11 @@ function getDropoffQuery() {
|
||||
const db = getDatabaseType(process.env.DATABASE_URL);
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return `round((1.0 - count::numeric/lag(count, 1) over ()),2)`;
|
||||
return `round((1.0 - count::numeric/lag(nullif(count, 0), 1) over ()),2) * 100`;
|
||||
}
|
||||
|
||||
if (db === MYSQL) {
|
||||
return `round((1.0 - count/LAG(count, 1) OVER (ORDER BY level)),2)`;
|
||||
return `round((1.0 - count/LAG(nullif(count, 0), 1) OVER (ORDER BY level)),2) * 100`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ function getFunnelQuery(
|
||||
and ${getAddMinutesQuery(`l.created_at `, windowMinutes)}
|
||||
and we.referrer_path = $${i + initParamLength}
|
||||
and we.url_path = $${levelNumber + initParamLength}
|
||||
and we.created_at between $2 and $3
|
||||
and we.website_id = $1${toUuid()}
|
||||
)`;
|
||||
}
|
||||
@@ -216,6 +217,8 @@ async function rawQuery(query: string, params: never[] = []): Promise<any> {
|
||||
|
||||
const sql = db === MYSQL ? query.replace(/\$[0-9]+/g, '?') : query;
|
||||
|
||||
// console.log(sql);
|
||||
// console.log(params);
|
||||
return prisma.rawQuery(sql, params);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user