From fa331df20332d2c748aab556eeddba4b14243760 Mon Sep 17 00:00:00 2001 From: Hikari Date: Thu, 19 Feb 2026 23:51:04 -0800 Subject: [PATCH] feat: add time tracking to all media types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements issue #57 with manual time entry functionality: - Added timeSpent field (stored in minutes) to all media models - Supports hours and minutes input in forms - Displays formatted time on media cards Database Schema: - Added timeSpent Int? field to Game, Book, Music, Show, and Manga models - Stored in minutes for consistency and easy calculation Shared Types: - Updated all media type interfaces with timeSpent? field - Added to CreateDto and main interfaces for all media types Frontend (Games - template for other types): - Added hour/minute input fields to Add and Edit forms - Split input with validation (minutes 0-59) - Auto-calculates total minutes on change - Formats display as "Xh Ym", "Xh", or "Ym" as appropriate - Green highlighted time display on cards with ⏱️ icon - Populates edit form from existing time data Implementation Notes: - Backend services require no changes (DTOs handle automatically) - Time conversion helpers for display and storage - Form state properly resets time fields - Edit mode correctly splits minutes back to hours/minutes Next Steps: - Apply same UI pattern to Books, Music, Shows, Manga - Add time statistics to user profiles - Consider aggregate time tracking views --- api/prisma/schema.prisma | 5 + .../components/games/games-list.component.ts | 118 +++++++++++++++++- shared-types/src/lib/book.types.ts | 2 + shared-types/src/lib/game.types.ts | 2 + shared-types/src/lib/manga.types.ts | 2 + shared-types/src/lib/music.types.ts | 2 + shared-types/src/lib/show.types.ts | 2 + 7 files changed, 132 insertions(+), 1 deletion(-) diff --git a/api/prisma/schema.prisma b/api/prisma/schema.prisma index 7ecca71..bbc01e0 100644 --- a/api/prisma/schema.prisma +++ b/api/prisma/schema.prisma @@ -34,6 +34,7 @@ model Game { links Link[] series String? seriesOrder Int? @db.Int + timeSpent Int? @db.Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt comments Comment[] @@ -62,6 +63,7 @@ model Book { links Link[] series String? seriesOrder Int? @db.Int + timeSpent Int? @db.Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt comments Comment[] @@ -89,6 +91,7 @@ model Music { coverArt String? tags String[] links Link[] + timeSpent Int? @db.Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt comments Comment[] @@ -135,6 +138,7 @@ model Show { coverImage String? tags String[] links Link[] + timeSpent Int? @db.Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt comments Comment[] @@ -168,6 +172,7 @@ model Manga { coverImage String? tags String[] links Link[] + timeSpent Int? @db.Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt comments Comment[] diff --git a/apps/frontend/src/app/components/games/games-list.component.ts b/apps/frontend/src/app/components/games/games-list.component.ts index aa24251..61a65a9 100644 --- a/apps/frontend/src/app/components/games/games-list.component.ts +++ b/apps/frontend/src/app/components/games/games-list.component.ts @@ -104,6 +104,34 @@ import { Game, GameStatus, CreateGameDto, UpdateGameDto, Comment, SuggestionEnti > +
+
+ + +
+
+ + +
+
+