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 29 30 | 26x 26x 1x 1x 1x 2x 23x | import type { SortResult } from "@/types";
import type { Database } from "@/lib/db";
import { SortResultRepository } from "@/server/repositories/implementations/SortResultRepository";
export class ResultController {
constructor(private resultRepo: SortResultRepository) {}
static fromDb(db: Database): ResultController {
return new ResultController(new SortResultRepository(db));
}
async getResult(resultId: string): Promise<SortResult> {
const result = await this.resultRepo.findById(resultId);
Iif (!result) {
throw new Error("Result not found");
}
return result;
}
// Returns null for an absent result so the caller maps it to notFound/404
// without masking a real DB error (mirrors ItemController.getItem).
async getResultOrNull(resultId: string): Promise<SortResult | null> {
return this.resultRepo.findById(resultId);
}
async getByCollectionAndNumber(collectionId: string, number: number): Promise<SortResult | null> {
return this.resultRepo.findByCollectionAndNumber(collectionId, number);
}
}
|