Anime list fetching not broken but ugly insted ✔️

This commit is contained in:
daru
2022-08-25 22:54:21 +02:00
parent beed95eed9
commit dbd34abea1
7 changed files with 34 additions and 26 deletions

View File

@@ -194,9 +194,9 @@ func SearchAppointments(animeId int64) ([]Appointment, error) {
return result, nil
}
func FetchProgress(animeId int64, username string) (int, time.Time, int, string, error) {
func FetchProgress(animeId int64, username string, refetch bool) (int, time.Time, int, string, error) {
// check watching first
newProgress, updated, score, err := FetchProgressOnState(animeId, username, malApiStatusW)
newProgress, updated, score, err := FetchProgressOnState(animeId, username, malApiStatusW, refetch)
if err != nil {
return newProgress, updated, score, "", err
}
@@ -204,7 +204,7 @@ func FetchProgress(animeId int64, username string) (int, time.Time, int, string,
return newProgress, updated, score, malApiStatusW, err
}
// check completed
newProgress, updated, score, err = FetchProgressOnState(animeId, username, malApiStatusC)
newProgress, updated, score, err = FetchProgressOnState(animeId, username, malApiStatusC, refetch)
if err != nil {
return newProgress, updated, score, "", err
}
@@ -212,7 +212,7 @@ func FetchProgress(animeId int64, username string) (int, time.Time, int, string,
return newProgress, updated, score, malApiStatusC, err
}
// check on hold
newProgress, updated, score, err = FetchProgressOnState(animeId, username, malApiStatusH)
newProgress, updated, score, err = FetchProgressOnState(animeId, username, malApiStatusH, refetch)
if err != nil {
return newProgress, updated, score, "", err
}
@@ -220,7 +220,7 @@ func FetchProgress(animeId int64, username string) (int, time.Time, int, string,
return newProgress, updated, score, malApiStatusH, err
}
// check dropped
newProgress, updated, score, err = FetchProgressOnState(animeId, username, malApiStatusD)
newProgress, updated, score, err = FetchProgressOnState(animeId, username, malApiStatusD, refetch)
if err != nil {
return newProgress, updated, score, "", err
}
@@ -231,8 +231,8 @@ func FetchProgress(animeId int64, username string) (int, time.Time, int, string,
return 0, updated, 0, "", nil
}
func FetchProgressOnState(animeId int64, username, malStatus string) (int, time.Time, int, error) {
list, _, err := GetUserAnimeListData(username, malStatus)
func FetchProgressOnState(animeId int64, username, malStatus string, refetch bool) (int, time.Time, int, error) {
list, _, err := GetUserAnimeListData(username, malStatus, refetch)
if err != nil {
return 0, time.Time{}, 0, err
}
@@ -327,7 +327,7 @@ func BuildMovieCharts() ([]MovieChart, error) {
scoreSum := 0
for _, u := range users {
progress, _, score, err := FetchProgressOnState(c.Anime, u.Username, malApiStatusC)
progress, _, score, err := FetchProgressOnState(c.Anime, u.Username, malApiStatusC, false)
if err != nil {
color.Errorln(err.Error())
continue