Label chapter chips by kind, not raw number

Beats, tags, locations, open questions, and character/arc-stage
responses that reference a chapter now carry a ChapterLabel/DisplayNumber
alongside the raw Number, computed via the new
ChapterDisplayNumberLookup. Front/back matter chips show their title;
body chapters show "Chapter N: Title".
This commit is contained in:
James Wampler
2026-08-19 18:02:53 -07:00
parent ef5260a111
commit 7f56c79b20
18 changed files with 407 additions and 88 deletions
+16 -2
View File
@@ -1,3 +1,4 @@
using Novelly.Api.Chapters;
using Novelly.Api.Common;
using Novelly.Api.Common.Validation;
@@ -45,8 +46,21 @@ public static class BeatEndpoints
.WithSummary("Move one or more beats to another chapter, appending them to its end.");
app.MapGet("/api/characters/{characterId:guid}/beats", async (
Guid characterId, BeatService service, CancellationToken ct) =>
(await service.ListForCharacterAsync(characterId, ct))?.Select(b => b.ToCharacterBeatResponse(characterId)).ToList().ToApiResult())
Guid characterId, BeatService service, ChapterDisplayNumberLookup chapterLabels, CancellationToken ct) =>
{
var characterBeats = await service.ListForCharacterAsync(characterId, ct);
if (characterBeats is null)
{
return Results.NotFound();
}
var displayNumbers = characterBeats.Count > 0
? await chapterLabels.ForNovelAsync(characterBeats[0].Chapter!.NovelId, ct)
: new Dictionary<Guid, int>();
return Results.Ok(characterBeats.Select(b =>
b.ToCharacterBeatResponse(characterId, b.Chapter is null ? null : chapterLabels.LabelFor(b.Chapter, displayNumbers))).ToList());
})
.WithTags("Beats")
.WithSummary("Every beat this character appears in, in manuscript order.");