feat: add schedule, notifications, and recommendations

This commit is contained in:
2026-04-08 13:02:17 +02:00
parent d035a6406b
commit 6f54ed16eb
21 changed files with 1884 additions and 329 deletions

View File

@@ -6,6 +6,7 @@ import (
"mal/internal/database"
"mal/internal/jikan"
"mal/internal/templates"
)
type Service struct {
@@ -59,3 +60,34 @@ func (s *Service) GetAnimeDetails(ctx context.Context, id int, userID string) (j
func (s *Service) GetRelations(id int) []jikan.RelationEntry {
return s.jikanClient.GetFullRelations(id)
}
func (s *Service) GetSchedule(day string) (jikan.ScheduleResult, error) {
return s.jikanClient.GetSchedule(day)
}
func (s *Service) GetRecommendations(animeID int) ([]jikan.Anime, error) {
return s.jikanClient.GetRecommendations(animeID)
}
func (s *Service) GetWatchingAnime(ctx context.Context, userID string) ([]templates.WatchingAnimeWithDetails, error) {
rows, err := s.db.GetWatchingAnime(ctx, userID)
if err != nil {
return nil, fmt.Errorf("failed to get watching anime: %w", err)
}
var result []templates.WatchingAnimeWithDetails
for _, row := range rows {
anime, err := s.jikanClient.GetAnimeByID(int(row.AnimeID))
if err != nil {
// Skip if we can't fetch anime details
continue
}
result = append(result, templates.WatchingAnimeWithDetails{
Entry: row,
Anime: anime,
})
}
return result, nil
}