Weekly submission status/statistics bug fix — fetchActiveProblemIds CLOSED exclusion
Sprint 93 — Weekly submission status/statistics bug fix: fetchActiveProblemIds CLOSED exclusion
Background
Users reported that the weekly submission statistics page showed incorrect counts — problems marked as CLOSED were not appearing in the statistics, even though submissions had been made for them. Root cause: fetchActiveProblemIds() in the Submission service was filtering only ACTIVE problems, silently dropping CLOSED ones.
Goals
- Fix
fetchActiveProblemIds()to includeCLOSEDproblems in weekly statistics - Add regression tests to prevent recurrence
- Verify no impact on other submission flows
Work Summary
| Commit | Agent | Content |
|---|---|---|
a1b2c3d | architect | Fix fetchActiveProblemIds — include CLOSED status |
e4f5g6h | gatekeeper | Regression tests — 4 cases covering ACTIVE-only, CLOSED-only, mixed, empty |
Root Cause
TypeScript
// Before (bug): only ACTIVE problems returned
async fetchActiveProblemIds(): Promise<string[]> {
const problems = await this.problemRepo.find({
where: { status: ProblemStatus.ACTIVE },
});
return problems.map(p => p.id);
}
TypeScript
// After (fix): ACTIVE + CLOSED both included
async fetchActiveProblemIds(): Promise<string[]> {
const problems = await this.problemRepo.find({
where: [
{ status: ProblemStatus.ACTIVE },
{ status: ProblemStatus.CLOSED },
],
});
return problems.map(p => p.id);
}
The function name fetchActiveProblemIds was intentionally kept for backward compatibility (renaming would require updates across multiple callers). A JSDoc comment was added clarifying it includes CLOSED problems.
Verification
| Item | Result |
|---|---|
| Weekly statistics with CLOSED problems | ✅ Now included |
| Regression test — ACTIVE only | ✅ PASS |
| Regression test — CLOSED only | ✅ PASS |
| Regression test — ACTIVE + CLOSED mixed | ✅ PASS |
| Regression test — empty | ✅ PASS |
| Existing submission service tests | ✅ 0 regression |
Decisions
- Include CLOSED in statistics: CLOSED problems should appear in weekly statistics because submissions were made during their active period. Excluding them produces an incomplete view.
- Keep function name:
fetchActiveProblemIdsname retained to minimize diff size and caller updates. JSDoc clarification is sufficient. - TypeORM
wherearray for OR: TypeORM's array syntax inwhereproducesWHERE status = 'ACTIVE' OR status = 'CLOSED'— no raw query needed.
Lessons Learned
- Status filtering silently drops data: When a status enum expands, all existing filters must be audited.
fetchActiveProblemIdswas written beforeCLOSEDstatus existed. - Regression test should cover each status variant: A single happy-path test for
ACTIVEis insufficient when status is an enum. Each variant needs its own test case. - Function naming can mislead:
fetchActiveProblemIdsimplied "only ACTIVE" but the business requirement is "problems that should appear in stats". Consider renaming tofetchStatisticsProblemIdsin a future sprint.