feat: Rename game to soundtrack throughout codebase

- Database migration: rename game table to soundtrack
- Rename game_name to soundtrack_name, game_id to soundtrack_id
- Update all SQL queries in soundtrack.sql, song.sql, song_list.sql, statistics.sql
- Regenerate sqlc code (soundtrack.sql.go, song.sql.go, etc.)
- Update backend: music.go, sync.go, statistics.go
- Update server: musicHandler.go, syncHandler.go, routes.go
- Update frontend: hello.go
- Keep URL paths as /games for backward compatibility

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-06-01 20:23:05 +02:00
parent c60f40d7e3
commit cec408187d
20 changed files with 760 additions and 694 deletions
+37 -37
View File
@@ -11,17 +11,17 @@ import (
// GameWithSongs represents a game with its songs for statistics
type GameWithSongs struct {
GameID int32 `json:"game_id"`
GameName string `json:"game_name"`
GamePlayed int32 `json:"game_played"`
GameLastPlayed *time.Time `json:"game_last_played,omitempty"`
SoundtrackID int32 `json:"game_id"`
SoundtrackName string `json:"game_name"`
SoundtrackPlayed int32 `json:"game_played"`
SoundtrackLastPlayed *time.Time `json:"game_last_played,omitempty"`
Songs []SongInfoForStats `json:"songs"`
}
// SongInfoForStats represents a song with game info for statistics
type SongInfoForStats struct {
GameID int32 `json:"game_id"`
GameName string `json:"game_name"`
SoundtrackID int32 `json:"game_id"`
SoundtrackName string `json:"game_name"`
SongName string `json:"song_name"`
Path string `json:"path"`
TimesPlayed int32 `json:"times_played"`
@@ -72,10 +72,10 @@ func (h *StatisticsHandler) GetMostPlayedGamesWithSongs(limit int32) ([]GameWith
}
}
result = append(result, GameWithSongs{
GameID: row.GameID,
GameName: row.GameName,
GamePlayed: row.GamePlayed,
GameLastPlayed: row.GameLastPlayed,
SoundtrackID: row.SoundtrackID,
SoundtrackName: row.SoundtrackName,
SoundtrackPlayed: row.SoundtrackPlayed,
SoundtrackLastPlayed: row.SoundtrackLastPlayed,
Songs: songs,
})
}
@@ -101,10 +101,10 @@ func (h *StatisticsHandler) GetLeastPlayedGamesWithSongs(limit int32) ([]GameWit
}
}
result = append(result, GameWithSongs{
GameID: row.GameID,
GameName: row.GameName,
GamePlayed: row.GamePlayed,
GameLastPlayed: row.GameLastPlayed,
SoundtrackID: row.SoundtrackID,
SoundtrackName: row.SoundtrackName,
SoundtrackPlayed: row.SoundtrackPlayed,
SoundtrackLastPlayed: row.SoundtrackLastPlayed,
Songs: songs,
})
}
@@ -124,8 +124,8 @@ func (h *StatisticsHandler) GetMostPlayedSongsWithGame(limit int32) ([]SongInfoF
var result []SongInfoForStats
for _, row := range rows {
result = append(result, SongInfoForStats{
GameID: row.GameID,
GameName: row.GameName,
SoundtrackID: row.SoundtrackID,
SoundtrackName: row.SoundtrackName,
SongName: row.SongName,
Path: row.Path,
TimesPlayed: row.TimesPlayed,
@@ -148,8 +148,8 @@ func (h *StatisticsHandler) GetLeastPlayedSongsWithGame(limit int32) ([]SongInfo
var result []SongInfoForStats
for _, row := range rows {
result = append(result, SongInfoForStats{
GameID: row.GameID,
GameName: row.GameName,
SoundtrackID: row.SoundtrackID,
SoundtrackName: row.SoundtrackName,
SongName: row.SongName,
Path: row.Path,
TimesPlayed: row.TimesPlayed,
@@ -178,10 +178,10 @@ func (h *StatisticsHandler) GetNeverPlayedGames() ([]GameWithSongs, error) {
}
}
result = append(result, GameWithSongs{
GameID: row.GameID,
GameName: row.GameName,
GamePlayed: row.GamePlayed,
GameLastPlayed: nil,
SoundtrackID: row.SoundtrackID,
SoundtrackName: row.SoundtrackName,
SoundtrackPlayed: row.SoundtrackPlayed,
SoundtrackLastPlayed: nil,
Songs: songs,
})
}
@@ -207,10 +207,10 @@ func (h *StatisticsHandler) GetLastPlayedGames(limit int32) ([]GameWithSongs, er
}
}
result = append(result, GameWithSongs{
GameID: row.GameID,
GameName: row.GameName,
GamePlayed: row.GamePlayed,
GameLastPlayed: row.GameLastPlayed,
SoundtrackID: row.SoundtrackID,
SoundtrackName: row.SoundtrackName,
SoundtrackPlayed: row.SoundtrackPlayed,
SoundtrackLastPlayed: row.SoundtrackLastPlayed,
Songs: songs,
})
}
@@ -236,10 +236,10 @@ func (h *StatisticsHandler) GetOldestPlayedGames(limit int32) ([]GameWithSongs,
}
}
result = append(result, GameWithSongs{
GameID: row.GameID,
GameName: row.GameName,
GamePlayed: row.GamePlayed,
GameLastPlayed: row.GameLastPlayed,
SoundtrackID: row.SoundtrackID,
SoundtrackName: row.SoundtrackName,
SoundtrackPlayed: row.SoundtrackPlayed,
SoundtrackLastPlayed: row.SoundtrackLastPlayed,
Songs: songs,
})
}
@@ -257,13 +257,13 @@ func (h *StatisticsHandler) GetStatisticsSummary() (*StatisticsSummary, error) {
}
return &StatisticsSummary{
TotalGames: int64(row.TotalGames),
PlayedGames: int64(row.PlayedGames),
NeverPlayedGames: int64(row.NeverPlayedGames),
TotalGamePlays: int64(row.TotalGamePlays),
AvgGamePlays: float64(row.AvgGamePlays),
MaxGamePlays: int64(row.MaxGamePlays),
MinGamePlays: int64(row.MinGamePlays),
TotalGames: int64(row.TotalSoundtracks),
PlayedGames: int64(row.PlayedSoundtracks),
NeverPlayedGames: int64(row.NeverPlayedSoundtracks),
TotalGamePlays: int64(row.TotalSoundtrackPlays),
AvgGamePlays: float64(row.AvgSoundtrackPlays),
MaxGamePlays: int64(row.MaxSoundtrackPlays),
MinGamePlays: int64(row.MinSoundtrackPlays),
}, nil
}