K oder R an den Kettenpfeilen anzeigen

This commit is contained in:
2026-09-22 10:15:18 +02:00
parent 823439f28d
commit 9b024d343d
4 changed files with 100 additions and 8 deletions
+24 -1
View File
@@ -633,7 +633,7 @@ export async function revertCharacter(
* überhaupt zu sehen ist.
*/
export async function listCharacters(playerId: number) {
return prisma.character.findMany({
const ccs = await prisma.character.findMany({
where: { members: { some: { playerId } } },
orderBy: [{ lineageId: 'asc' }, { chainPosition: 'asc' }, { createdAt: 'asc' }],
include: {
@@ -657,6 +657,29 @@ export async function listCharacters(playerId: number) {
},
},
});
// Womit dieser Spieler den jeweiligen Eintrag bezahlt hat. In der Kette
// steht das am Übergang: der Pfeil zum nächsten Glied trägt die Art, mit
// der dieses Glied bezahlt wurde.
const buchungen = await prisma.creditLedger.findMany({
where: {
characterId: { in: ccs.map((c) => c.id) },
playerId,
source: CreditSource.CONSUME,
reversedBy: null,
},
select: { characterId: true, kind: true },
orderBy: { id: 'desc' },
});
const artNach = new Map<number, CreditKind>();
for (const buchung of buchungen) {
if (buchung.characterId !== null && !artNach.has(buchung.characterId)) {
artNach.set(buchung.characterId, buchung.kind);
}
}
return ccs.map((cc) => ({ ...cc, fundedWith: artNach.get(cc.id) ?? null }));
}