📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Add missing isCaptchaDataExists check
Blue Mouse4254bae87154
diff --git a/backend/apps/community/src/project/project.controller.ts b/backend/apps/community/src/project/project.controller.tsindex 082c447ae..d8e1e4ef4 100644--- a/backend/apps/community/src/project/project.controller.ts+++ b/backend/apps/community/src/project/project.controller.ts@@ -1167,13 +1167,16 @@ export class ProjectController {this.projectService.allowedToView(project, userId, headers['x-password'])- const isDataExists = !_isEmpty(- await this.projectService.getPIDsWhereAnalyticsDataExists([id]),- )-- const isErrorDataExists = !_isEmpty(- await this.projectService.getPIDsWhereErrorsDataExists([id]),- )+ const [isDataExists, isErrorDataExists, isCaptchaDataExists] =+ await Promise.all([+ !_isEmpty(+ await this.projectService.getPIDsWhereAnalyticsDataExists([id]),+ ),+ !_isEmpty(await this.projectService.getPIDsWhereErrorsDataExists([id])),+ !_isEmpty(+ await this.projectService.getPIDsWhereCaptchaDataExists([id]),+ ),+ ])const funnels = await getFunnelsClickhouse(id)const rawShares = await findProjectSharesByProjectClickhouse(id)@@ -1216,6 +1219,7 @@ export class ProjectController {funnels: this.projectService.formatFunnelsFromClickhouse(funnels),isDataExists,isErrorDataExists,+ isCaptchaDataExists,role,isLocked: false,isAccessConfirmed,diff --git a/backend/apps/community/src/project/project.service.ts b/backend/apps/community/src/project/project.service.tsindex b8d679c0a..05ee95729 100644--- a/backend/apps/community/src/project/project.service.ts+++ b/backend/apps/community/src/project/project.service.ts@@ -339,6 +339,55 @@ export class ProjectService {return _map(data, ({ pid }) => pid)}+ async getPIDsWhereCaptchaDataExists(projectIds: string[]): Promise<string[]> {+ if (_isEmpty(projectIds)) {+ return []+ }++ const params = _reduce(+ projectIds,+ (acc, curr, index) => ({+ ...acc,+ [`pid_${index}`]: curr,+ }),+ {},+ )++ const pids = _join(+ _map(params, (val, key) => `{${key}:FixedString(12)}`),+ ',',+ )++ const query = `+ SELECT+ pid,+ CASE+ WHEN EXISTS (+ SELECT 1+ FROM captcha+ WHERE pid IN (${pids})+ )+ THEN 1+ ELSE 0+ END AS exists+ FROM+ (+ SELECT DISTINCT pid+ FROM captcha+ WHERE pid IN (${pids})+ );+ `++ const { data } = await clickhouse+ .query({+ query,+ query_params: params,+ })+ .then(resultSet => resultSet.json<{ pid: string }>())++ return _map(data, ({ pid }) => pid)+ }+async removeDataFromClickhouse(pid: string,from: string,