Flesh-out model on the backend

This commit is contained in:
Szymon Nowakowski
2024-12-26 21:40:05 +01:00
parent 8e57a76e60
commit 1d2b19f072
6 changed files with 460 additions and 113 deletions

View File

@@ -87,25 +87,12 @@ export const denormalizePiece = ({
Effect.flatMap(denormalizeSystemInformation),
);
export const denormalizeRepertoireEntry = ({
pieceId,
...rest
}: Db.RepertoireEntry) => pipe(
Effect.all({
piece: Effect.uninterruptible(pieceCache.get(pieceId)),
}, { concurrency: "unbounded" }),
Effect.map((entry) => Object.freeze({
...rest,
...entry,
})),
);
export const denormalizeRepertoire = ({
entries,
...rest
}: Db.Repertoire & { entries: Db.RepertoireEntry[] }) => pipe(
}: Db.Repertoire & { entries: PieceId[] }) => pipe(
Effect.all({
entries: Effect.all(entries.map(denormalizeRepertoireEntry), { concurrency: "unbounded" }),
entries: Effect.all(entries.map((entry) => Effect.uninterruptible(pieceCache.get(entry))), { concurrency: "unbounded" }),
}, { concurrency: "unbounded" }),
Effect.map((repertoire) => Object.freeze({
...rest,