All files / src/server/api decisions.ts

80% Statements 4/5
100% Branches 0/0
75% Functions 3/4
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                7x 7x       7x                     8x      
import type { Database } from "@/lib/db";
import type { DecisionEvent } from "@/types";
import { DecisionEventRepository } from "@/server/repositories/implementations/DecisionEventRepository";
import { SessionRepository } from "@/server/repositories/implementations/SessionRepository";
import { loadCuratorDecisionEvents } from "@/server/services/decision-log";
 
export class DecisionController {
  constructor(
    private decisionRepo: DecisionEventRepository,
    private sessionRepo: SessionRepository,
  ) {}
 
  static fromDb(db: Database): DecisionController {
    return new DecisionController(new DecisionEventRepository(db), new SessionRepository(db));
  }
 
  async listBySession(sessionId: string): Promise<DecisionEvent[]> {
    return this.decisionRepo.findBySession(sessionId);
  }
 
  // The curator's WHOLE cross-session decision log (spec §2.6) — same shared
  // definition the recompute reads, so an item answered in one session is never
  // re-asked by another session's queue.
  async listForCurator(collectionId: string, curatorId: string): Promise<DecisionEvent[]> {
    return loadCuratorDecisionEvents(this.sessionRepo, this.decisionRepo, collectionId, curatorId);
  }
}