More story fixes

This commit is contained in:
gamer147
2026-05-25 19:07:49 -04:00
parent ce8d80559b
commit fa0901b776
16 changed files with 6361 additions and 48 deletions

View File

@@ -16,4 +16,12 @@ public interface IStoryMasterRepository
Task<StoryChapter?> GetChapterByIdAsync(int storyId);
Task<SpecialBattleSetting?> GetSbsByIdAsync(int sbsId);
/// <summary>
/// Resolve a wire story_id to a sub-chapter row when no top-level <see cref="StoryChapter"/>
/// exists for it. Sub-chapter story_ids have no chapter master data of their own — they're
/// progress markers hanging off the parent. Used by /finish to record progress at the sub's
/// story_id when the client sends sub-chapter ids directly.
/// </summary>
Task<StorySubChapter?> FindSubChapterByStoryIdAsync(int storyId);
}

View File

@@ -51,4 +51,15 @@ public class StoryMasterRepository : IStoryMasterRepository
public Task<SpecialBattleSetting?> GetSbsByIdAsync(int sbsId)
=> _db.SpecialBattleSettings.FirstOrDefaultAsync(s => s.Id == sbsId);
public async Task<StorySubChapter?> FindSubChapterByStoryIdAsync(int storyId)
{
// StorySubChapter is an owned entity (no DbSet of its own); query through the owning
// chapter. SelectMany over the owned collection translates to a JOIN in the relational
// provider — no need to materialize the full chapter row.
return await _db.StoryChapters
.AsNoTracking()
.SelectMany(c => c.SubChapters)
.FirstOrDefaultAsync(sc => sc.SubChapterStoryId == storyId);
}
}