Skip to content

Commit

Permalink
feat: refactor if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrvlh committed Nov 21, 2024
1 parent 5ca87dd commit d99b822
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/queries/analytics/reports/getFunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,18 @@ async function relationalQuery(
(pv, cv, i) => {
const levelNumber = i + 1;
const startSum = i > 0 ? 'union ' : '';
const column = cv.type === 'url' ? 'url_path' : 'event_name';
const isURL = cv.type === 'url';
const column = isURL ? 'url_path' : 'event_name';

let operator: string;
let paramValue: string;
let operator = '=';
let paramValue = cv.value;

if (cv.type === 'url') {
if (cv.value.includes('*')) {
operator = '~';
paramValue = cv.value.replace(/\*/g, '.*');
} else if (cv.value.endsWith('*')) {
operator = 'like';
paramValue = cv.value.replace('*', '%');
} else {
operator = '=';
paramValue = cv.value;
}
} else {
operator = '=';
paramValue = cv.value;
if (isURL && cv.value.includes('*')) {
operator = '~';
paramValue = cv.value.replace(/\*/g, '.*');
} else if (isURL && cv.value.endsWith('*')) {
operator = 'like';
paramValue = cv.value.replace('*', '%');
}

if (levelNumber === 1) {
Expand Down

0 comments on commit d99b822

Please sign in to comment.