Skip to content

feat(analytics): register ScheduleModule in AnalyticsModule - #653

Open
1Judah wants to merge 1 commit into
MindBlockLabs:mainfrom
1Judah:feat/issue-545-configure-schedule-module-analytics
Open

feat(analytics): register ScheduleModule in AnalyticsModule#653
1Judah wants to merge 1 commit into
MindBlockLabs:mainfrom
1Judah:feat/issue-545-configure-schedule-module-analytics

Conversation

@1Judah

@1Judah 1Judah commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Closes #545

Registers ScheduleModule.forRoot() inside AnalyticsModule and adds the corresponding import so the module explicitly declares its dependency on the NestJS task-scheduler. The dependency @nestjs/schedule was already present in backend/package.json at ^6.0.0 (installed: v6.1.0); this change wires it into the module that actually owns the three cron-job providers.

Why

Before this change, AnalyticsModule registered DailyActiveUsersRollupJob, QuestAnalyticsRollupJob, and RetentionCohortRollupJob as providers, and each of those classes decorates its handleCron method with @Cron(). However, AnalyticsModule never imported ScheduleModule, meaning the module did not explicitly declare the scheduling dependency it required. ScheduleModule.forRoot() was present in AppModule and kept the decorators functional at runtime, but that represented an implicit, fragile coupling — removing or restructuring AppModule could silently break all three rollup jobs without any compile-time or module-level signal.

Adding ScheduleModule.forRoot() to AnalyticsModule makes the dependency explicit at the module boundary, which is consistent with the project's pattern of self-describing feature modules.

What was built

File What it contains
backend/src/analytics/analytics.module.ts Added import { ScheduleModule } from '@nestjs/schedule' and ScheduleModule.forRoot() as the first entry in the imports array. Removed the pre-existing spurious blank line inside the @Module decorator to satisfy prettier.

No new source files were added. The three rollup-job classes and their @Cron()-decorated handleCron methods are unchanged.

Integration changes outside analytics/

No existing files outside backend/src/analytics/analytics.module.ts were modified; the implementation is purely additive within the analytics module.

Acceptance criteria coverage

  • @nestjs/schedule added to backend/package.json — already present at ^6.0.0 (v6.1.0 installed) before this PR; confirmed via package.json line 32 and node_modules/@nestjs/schedule/package.json.
  • ScheduleModule registered without breaking existing module bootstrap — ScheduleModule.forRoot() added to AnalyticsModule imports; 180/180 tests pass and production build succeeds with zero new errors.

Deliberately deferred

None. Both acceptance criteria are fully satisfied by this PR.

Test plan

  • npm --workspace backend run test -- --forceExit — 180/180 passing (0 new tests; existing job specs cover @Cron-decorated handlers)
  • npx tsc -p tsconfig.build.json --noEmit — 0 type errors
  • npx eslint src/analytics/analytics.module.ts — 0 errors, 0 warnings
  • npm --workspace backend run build — succeeds (exit 0)

Env vars / Notes

No new environment variables are introduced. ScheduleModule.forRoot() accepts no configuration here — the default scheduler options (using the system clock, no timezone override) are appropriate for UTC-anchored nightly rollups already hardcoded in the job classes.

Add ScheduleModule.forRoot() to AnalyticsModule imports so the module
explicitly declares its dependency on the NestJS task-scheduler. The
three cron-job providers already registered in this module
(DailyActiveUsersRollupJob, QuestAnalyticsRollupJob,
RetentionCohortRollupJob) rely on @Cron() decorators from
@nestjs/schedule, which is already present in backend/package.json.

Closes MindBlockLabs#545
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
mind-block-app-frontend Skipped Skipped Aug 22, 2026 4:33pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add @nestjs/schedule and configure a cron module for analytics

1 participant