feat(stats): add episodes completed and anime completed to tracking snapshot

- Query watched videos count and anime with all episodes watched
- Display in overview tracking snapshot
- Remove efficiency section from trends
This commit is contained in:
2026-03-14 22:31:17 -07:00
parent 249a7cada8
commit ff2d9141bc
6 changed files with 39 additions and 6 deletions

View File

@@ -49,7 +49,7 @@ test('buildOverviewSummary aggregates tracked totals and recent windows', () =>
const overview: OverviewData = {
sessions,
rollups,
hints: { totalSessions: 1, activeSessions: 0, episodesToday: 2, activeAnimeCount: 3 },
hints: { totalSessions: 1, activeSessions: 0, episodesToday: 2, activeAnimeCount: 3, totalEpisodesWatched: 5, totalAnimeCompleted: 1 },
};
const summary = buildOverviewSummary(overview, now);

View File

@@ -14,6 +14,8 @@ export interface OverviewSummary {
totalTrackedCards: number;
episodesToday: number;
activeAnimeCount: number;
totalEpisodesWatched: number;
totalAnimeCompleted: number;
averageSessionMinutes: number;
totalSessions: number;
activeDays: number;
@@ -146,6 +148,8 @@ export function buildOverviewSummary(
totalTrackedCards: Math.max(sessionCards, rollupCards),
episodesToday: overview.hints.episodesToday ?? 0,
activeAnimeCount: overview.hints.activeAnimeCount ?? 0,
totalEpisodesWatched: overview.hints.totalEpisodesWatched ?? 0,
totalAnimeCompleted: overview.hints.totalAnimeCompleted ?? 0,
averageSessionMinutes:
overview.sessions.length > 0
? Math.round(sumBy(overview.sessions, (session) => session.activeWatchedMs) / overview.sessions.length / 60_000)