feat: add schedule, notifications, and recommendations
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user