📈 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
added user quarterly reports
Blue Mouse83f0f4d0c300
diff --git a/src/task-manager/task-manager.service.ts b/src/task-manager/task-manager.service.tsindex 91aba2104..e93fe3c0f 100644--- a/src/task-manager/task-manager.service.ts+++ b/src/task-manager/task-manager.service.ts@@ -307,6 +307,51 @@ export class TaskManagerService {}}+ @Cron(CronExpression.EVERY_QUARTER)+ async quarterlyReportsHandler(): Promise<void> {+ if (isSelfhosted) {+ return+ }++ const users = await this.userService.find({+ where: {+ reportFrequency: ReportFrequency.QUARTERLY,+ },+ relations: ['projects'],+ select: ['email'],+ })+ const now = dayjs.utc().format('DD.MM.YYYY')+ const quarterAgo = dayjs.utc().subtract(3, 'M').format('DD.MM.YYYY')+ const date = `${quarterAgo} - ${now}`+ const tip = getRandomTip()++ for (let i = 0; i < _size(users); ++i) {+ if (_isEmpty(users[i]?.projects) || _isNull(users[i]?.projects)) {+ continue+ }++ const ids = _map(users[i].projects, p => p.id)+ const data = await this.analyticsService.getSummary(ids, 'M')++ const result = {+ type: 'Q', // quarterly+ date,+ projects: _map(ids, (pid, index) => ({+ data: data[pid],+ name: users[i].projects[index].name,+ })),+ tip,+ }++ await this.mailerService.sendEmail(+ users[i].email,+ LetterTemplate.ProjectReport,+ result,+ 'broadcast',+ )+ }+ }+// EMAIL REPORTS, BUT FOR MULTIPLE PROJECT SUBSCRIBERS@Cron(CronExpression.EVERY_QUARTER)diff --git a/src/user/entities/user.entity.ts b/src/user/entities/user.entity.tsindex e9e35b6cf..7e4f140d1 100644--- a/src/user/entities/user.entity.ts+++ b/src/user/entities/user.entity.ts@@ -108,6 +108,7 @@ export enum ReportFrequency {Never = 'never',Weekly = 'weekly',Monthly = 'monthly',+ Quarterly = 'quarterly',}export enum BillingFrequency {