Skip to content

ProgressService recalculates and writes on every read #52

Description

@mercy60

Internal ID: #51

Imported from ISSUES.md via scripts/import-issues.mjs.

Problem Statement. backend/src/progress/progress.service.ts:

const percentComplete = (progress.completedPuzzles / progress.totalPuzzles) * 100;
progress.percentComplete = parseFloat(percentComplete.toFixed(2));
await this.progressRepo.save(progress);

Every read is also a write. Under load this multiplies DB traffic.

Expected Outcome.

  • Percent is computed inline at read time (it's a derived field); remove percentComplete from persistence or compute via DB computed column.
  • Or: maintain lastUpdated from totals change.

Acceptance Criteria.

  • No write on read. Load test confirms.

Implementation Notes.

  • Add @AfterLoad hook (progress.percentComplete = compute(...)).

Files / modules affected.

  • backend/src/progress/progress.service.ts
  • backend/src/progress/progress.entity.ts

Dependencies. None.

Difficulty / Effort. Easy / S (≈ 2 hours).

Labels. area:backend, performance, tech-debt

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programarea:backendImported from ISSUES.mdperformanceImported from ISSUES.mdtech-debtImported from ISSUES.md

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions