aboutsummaryrefslogtreecommitdiff
path: root/repositories/seasons.go
blob: 011eda2b6bc948a71feba191daa14a14768521de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package repositories

import (
	"metachan/entities"
	"metachan/utils/logger"
)

func GetRelatedAnimeByTVDB(tvdbID int, excludeMALID int) ([]entities.Mapping, error) {
	var mappings []entities.Mapping

	result := DB.Where("tvdb = ? AND mal != ?", tvdbID, excludeMALID).Order("mal ASC").Find(&mappings)
	if result.Error != nil {
		logger.Errorf("Seasons", "Failed to get related anime by TVDB ID %d: %v", tvdbID, result.Error)
		return nil, result.Error
	}

	logger.Debugf("Seasons", "Found %d related anime via TVDB ID %d", len(mappings), tvdbID)
	return mappings, nil
}

func GetRelatedAnimeByTMDB(tmdbID int, excludeMALID int) ([]entities.Mapping, error) {
	var mappings []entities.Mapping

	result := DB.Where("tmdb = ? AND mal != ?", tmdbID, excludeMALID).Order("mal ASC").Find(&mappings)
	if result.Error != nil {
		logger.Errorf("Seasons", "Failed to get related anime by TMDB ID %d: %v", tmdbID, result.Error)
		return nil, result.Error
	}

	logger.Debugf("Seasons", "Found %d related anime via TMDB ID %d", len(mappings), tmdbID)
	return mappings, nil
}