Skip to content

Feature/ Grit-metre - #6

Merged
nanda-kshr merged 4 commits into
devfrom
main
Aug 4, 2026
Merged

Feature/ Grit-metre#6
nanda-kshr merged 4 commits into
devfrom
main

Conversation

@nanda-kshr

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings August 4, 2026 06:14
@nanda-kshr
nanda-kshr merged commit 160e767 into dev Aug 4, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the existing scheduler/jobs functionality into a modules/jobs structure, introduces a new “Grit Meter” feature (cron + manual trigger) that performs daily DB-driven updates, and updates project configuration (TypeScript paths, env vars, CI branch targeting) to align with the deployment environment.

Changes:

  • Replaced the legacy src/scheduler/* module/tests with a new src/modules/jobs/* module layout and naming (Scheduler*Jobs*).
  • Added a new GritMeterModule with a daily cron job and an HTTP endpoint to run processing on demand.
  • Updated config: tsconfig output/paths, .env.example database variables, and CI workflow branch trigger.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tsconfig.json Switches TS module/target settings and adds path aliases.
src/scheduler/scheduler.module.ts Removes legacy scheduler Nest module (replaced by JobsModule).
src/scheduler/scheduler.controller.spec.ts Removes legacy e2e test coverage for jobs endpoints.
src/modules/jobs/jobs.service.ts Renames/refactors scheduler service into JobsService.
src/modules/jobs/jobs.module.ts Introduces JobsModule wiring for controller/service/runner/repository.
src/modules/jobs/jobs.controller.ts Renames controller to JobsController and rebinds to JobsService.
src/modules/jobs/job-runner.service.ts Keeps job runner behavior while trimming inline comments/formatting.
src/modules/jobs/entities/job.entity.ts Adds JobEntity under the new module path.
src/modules/jobs/dto/create-job.dto.ts Simplifies DTO validation (notably scheduling).
src/modules/grit-meter/grit-meter.service.ts Adds daily grit-meter processing logic, feature flag, and webhook dispatch.
src/modules/grit-meter/grit-meter.module.ts Registers grit-meter controller/service and exports the service.
src/modules/grit-meter/grit-meter.controller.ts Adds POST /grit-meter/process endpoint to trigger processing.
src/guards/api-key.guard.ts Removes old guard location (moved under src/common).
src/common/guards/api-key.guard.ts Adds guard in shared location and supports SCHEDULER_SERVICE_API_KEY.
src/app.module.ts Wires JobsModule + GritMeterModule, updates DB config/env keys, sets global API key guard.
.github/workflows/main.yml Changes CI trigger branch from main to production.
.env.example Updates env variable names/defaults and adds webhook/API key examples.
Suppressed comments (2)

src/modules/jobs/dto/create-job.dto.ts:68

  • scheduling is now an untyped any with no validation. Since downstream scheduling logic relies on keys like execute_at (oneoff) and cron (recurring), invalid payloads can be accepted and then silently never run (or log warnings only). Consider restoring conditional validation (e.g., ValidateIf + nested DTOs or a custom validator) so the API rejects malformed schedules at the boundary.
    src/modules/jobs/jobs.controller.ts:12
  • The jobs API was renamed/restructured (Scheduler* -> Jobs*), but there are no tests covering POST /jobs, listing, or deletions anymore (only AppController is tested). Please add/restore controller/e2e coverage for these endpoints to ensure scheduling and persistence behavior remains correct.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +73 to +77
for (const link of userLinks) {
const activityResult: Array<{ activity_count: number }> = await queryRunner.query(
`
SELECT COUNT(*) AS activity_count
FROM karma_activity_log
Comment on lines +45 to +51
const queryRunner = this.dataSource.createQueryRunner();
await queryRunner.connect();

let processedCount = 0;
let levelDownCount = 0;

try {
Comment on lines +36 to +40
async processDailyGritMeter(): Promise<{ processed: number; levelDowns: number }> {
this.logger.log('Starting Daily Grit Meter / HP Processing');

const isEnabled = await this.checkFeatureFlag();
if (!isEnabled) {
Comment on lines +8 to +12
@Post('process')
async processGritMeter() {
const result = await this.gritMeterSvc.processDailyGritMeter();
return { success: true, ...result };
}
Comment thread .env.example
@@ -1,13 +1,17 @@
# MySQL example
DB_TYPE=mysql
# Database Config (Matches mulearnbackend)
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.

3 participants