📈 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
fixed broken plan usage query
Blue Mousec974b6584a96
diff --git a/apps/production/src/task-manager/task-manager.service.ts b/apps/production/src/task-manager/task-manager.service.tsindex 638961f67..5047e744c 100644--- a/apps/production/src/task-manager/task-manager.service.ts+++ b/apps/production/src/task-manager/task-manager.service.ts@@ -111,6 +111,8 @@ const generatePlanUsageQuery = (): string => {let query = ''+ console.log('users:', users)+for (let i = 0; i < _size(users); ++i) {const user = users[i]const pidsStringified = _map(user.projects, p => `'${p.id}'`).join(',')@@ -129,6 +131,10 @@ const generatePlanUsageQuery = (return query}+const filterUsersWithEmptyProjects = (users: User[]) => {+ return _filter(users, (user: User) => !_isEmpty(user.projects))+}+const getUsersThatExceedPlanUsage = (users: User[],usage: CHPlanUsage[],@@ -306,17 +312,19 @@ export class TaskManagerService {.subtract(7, 'days').format('YYYY-MM-DD HH:mm:ss')- const users = await this.userService.find({- where: {- isActive: true,- planCode: Not(PlanCode.none),- planExceedContactedAt: MoreThan(sevenDaysAgo),- dashboardBlockReason: IsNull(),- isAccountBillingSuspended: false,- },- relations: ['projects'],- select: ['id', 'email', 'planCode'],- })+ const users = filterUsersWithEmptyProjects(+ await this.userService.find({+ where: {+ isActive: true,+ planCode: Not(PlanCode.none),+ planExceedContactedAt: MoreThan(sevenDaysAgo),+ dashboardBlockReason: IsNull(),+ isAccountBillingSuspended: false,+ },+ relations: ['projects'],+ select: ['id', 'email', 'planCode'],+ }),+ )if (_isEmpty(users)) {return@@ -362,19 +370,21 @@ export class TaskManagerService {})}- @Cron(CronExpression.EVERY_DAY_AT_4PM)+ @Cron(CronExpression.EVERY_10_SECONDS)async checkPlanUsage(): Promise<void> {- const users = await this.userService.find({- where: {- isActive: true,- planCode: Not(PlanCode.none),- planExceedContactedAt: IsNull(),- dashboardBlockReason: IsNull(),- isAccountBillingSuspended: false,- },- relations: ['projects'],- select: ['id', 'email', 'planCode'],- })+ const users = filterUsersWithEmptyProjects(+ await this.userService.find({+ where: {+ isActive: true,+ planCode: Not(PlanCode.none),+ planExceedContactedAt: IsNull(),+ dashboardBlockReason: IsNull(),+ isAccountBillingSuspended: false,+ },+ relations: ['projects'],+ select: ['id', 'email', 'planCode'],+ }),+ )if (_isEmpty(users)) {return