feat(analytics): register ScheduleModule in AnalyticsModule - #653
Open
1Judah wants to merge 1 commit into
Open
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #545
Registers
ScheduleModule.forRoot()insideAnalyticsModuleand adds the corresponding import so the module explicitly declares its dependency on the NestJS task-scheduler. The dependency@nestjs/schedulewas already present inbackend/package.jsonat^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,
AnalyticsModuleregisteredDailyActiveUsersRollupJob,QuestAnalyticsRollupJob, andRetentionCohortRollupJobas providers, and each of those classes decorates itshandleCronmethod with@Cron(). However,AnalyticsModulenever importedScheduleModule, meaning the module did not explicitly declare the scheduling dependency it required.ScheduleModule.forRoot()was present inAppModuleand kept the decorators functional at runtime, but that represented an implicit, fragile coupling — removing or restructuringAppModulecould silently break all three rollup jobs without any compile-time or module-level signal.Adding
ScheduleModule.forRoot()toAnalyticsModulemakes the dependency explicit at the module boundary, which is consistent with the project's pattern of self-describing feature modules.What was built
backend/src/analytics/analytics.module.tsimport { ScheduleModule } from '@nestjs/schedule'andScheduleModule.forRoot()as the first entry in theimportsarray. Removed the pre-existing spurious blank line inside the@Moduledecorator to satisfy prettier.No new source files were added. The three rollup-job classes and their
@Cron()-decoratedhandleCronmethods are unchanged.Integration changes outside
analytics/Acceptance criteria coverage
@nestjs/scheduleadded tobackend/package.json— already present at^6.0.0(v6.1.0 installed) before this PR; confirmed viapackage.jsonline 32 andnode_modules/@nestjs/schedule/package.json.ScheduleModuleregistered without breaking existing module bootstrap —ScheduleModule.forRoot()added toAnalyticsModuleimports; 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 errorsnpx eslint src/analytics/analytics.module.ts— 0 errors, 0 warningsnpm --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.