All files / src/server/services decision-log.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 2/2
100% Lines 2/2

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                              135x 135x    
import type { DecisionEvent } from "@/types";
import type { SessionRepository } from "@/server/repositories/implementations/SessionRepository";
import type { DecisionEventRepository } from "@/server/repositories/implementations/DecisionEventRepository";
 
// THE definition of "the curator's decision log" — the recompute and the round
// page provably read the same log (spec §2.6). Body is the former private
// PreferenceStateService.loadDecisionEvents, verbatim: the curator's non-deleted
// sessions' decision events, fetched in one query
// (findByCollectionAndCurator yields the same session set the scorer scopes to).
export async function loadCuratorDecisionEvents(
  sessionRepo: SessionRepository,
  decisionRepo: DecisionEventRepository,
  collectionId: string,
  curatorId: string,
): Promise<DecisionEvent[]> {
  const sessions = await sessionRepo.findByCollectionAndCurator(collectionId, curatorId);
  return decisionRepo.findBySessions(sessions.map((s) => s.id));
}