Weekly submission status/statistics bug fix — fetchActiveProblemIds CLOSED exclusion
Key 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
fetchActiveProblemIds name retained to minimize diff size and caller updates. JSDoc clarification is sufficient.
TypeORM `where` array for OR
TypeORM's array syntax in where produces WHERE status = 'ACTIVE' OR status = 'CLOSED' — no raw query needed.
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
// 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);
}
// 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.