Add GitHub-style activity contribution graph
CI / build-and-push (push) Successful in 52s
CI / deploy (push) Successful in 9s

Record create/update/delete events across novel content (chapters, beats,
characters, arc stages, tags, locations, questions) into an append-only
ActivityEvent log, aggregate by UTC day, and surface as a heatmap on the
novels list and each novel's dashboard. Backfills history from existing
CreatedAt timestamps on first boot after the migration.
This commit is contained in:
James Wampler
2026-08-19 17:39:13 -07:00
parent 51f3176bd0
commit 71953220aa
28 changed files with 2113 additions and 20 deletions
+13 -8
View File
@@ -1,3 +1,4 @@
using Novelly.Api.Activity;
using Novelly.Api.Beats;
using Novelly.Api.Chapters;
using Novelly.Api.Characters;
@@ -15,6 +16,8 @@ public abstract class ServiceTestFixture
protected TestDatabase Db { get; private set; } = null!;
protected TestUserContext UserContext { get; private set; } = null!;
protected NovelAccessService Access { get; private set; } = null!;
protected ActivityLog ActivityLog { get; private set; } = null!;
protected ActivityService Activity { get; private set; } = null!;
protected TagService Tags { get; private set; } = null!;
protected LocationService Locations { get; private set; } = null!;
protected NovelService Novels { get; private set; } = null!;
@@ -41,6 +44,8 @@ public abstract class ServiceTestFixture
Db = new TestDatabase();
UserContext = new TestUserContext();
Access = new NovelAccessService(Db.Context, UserContext, new CapturingLogger<NovelAccessService>());
ActivityLog = new ActivityLog(Db.Context, UserContext, new CapturingLogger<ActivityLog>());
Activity = new ActivityService(Db.Context, Access, new CapturingLogger<ActivityService>());
Db.Context.Users.Add(new NovellyUser
{
@@ -62,25 +67,25 @@ public abstract class ServiceTestFixture
QuestionLogs = new CapturingLogger<OpenQuestionService>();
GenreLogs = new CapturingLogger<GenreService>();
Tags = new TagService(Db.Context, Access, TagLogs, new CreateTagRequestValidator(), new UpdateTagRequestValidator());
Locations = new LocationService(Db.Context, Access, LocationLogs, new CreateLocationRequestValidator(), new UpdateLocationRequestValidator());
Tags = new TagService(Db.Context, Access, ActivityLog, TagLogs, new CreateTagRequestValidator(), new UpdateTagRequestValidator());
Locations = new LocationService(Db.Context, Access, ActivityLog, LocationLogs, new CreateLocationRequestValidator(), new UpdateLocationRequestValidator());
Novels = new NovelService(
Db.Context, Access, UserContext, NovelLogs, new CreateNovelRequestValidator(), new UpdateNovelRequestValidator());
Db.Context, Access, UserContext, ActivityLog, NovelLogs, new CreateNovelRequestValidator(), new UpdateNovelRequestValidator());
Characters = new CharacterService(
Db.Context, Access, Tags, CharacterLogs,
Db.Context, Access, Tags, ActivityLog, CharacterLogs,
new CreateCharacterRequestValidator(), new UpdateCharacterRequestValidator(), new CreateRelationshipRequestValidator(),
new LinkCharacterIdentityRequestValidator());
Chapters = new ChapterService(Db.Context, Access, Tags, Locations, ChapterLogs, new CreateChapterRequestValidator(), new UpdateChapterRequestValidator());
Chapters = new ChapterService(Db.Context, Access, Tags, Locations, ActivityLog, ChapterLogs, new CreateChapterRequestValidator(), new UpdateChapterRequestValidator());
Beats = new BeatService(
Db.Context, Access, Tags, BeatLogs,
Db.Context, Access, Tags, ActivityLog, BeatLogs,
new CreateBeatRequestValidator(), new UpdateBeatRequestValidator(), new ReorderBeatsRequestValidator(),
new AssignCharacterToBeatsRequestValidator(), new MoveBeatsRequestValidator());
Arcs = new CharacterArcService(
Db.Context, Access, ArcLogs,
Db.Context, Access, ActivityLog, ArcLogs,
new CreateArcStageRequestValidator(), new UpdateArcStageRequestValidator(), new ReorderArcStagesRequestValidator(),
new SetArcStageBeatsRequestValidator());
Questions = new OpenQuestionService(
Db.Context, Access, QuestionLogs,
Db.Context, Access, ActivityLog, QuestionLogs,
new CreateOpenQuestionRequestValidator(), new UpdateOpenQuestionRequestValidator(), new ResolveOpenQuestionRequestValidator());
Genres = new GenreService(Db.Context, GenreLogs);