fix(worker): use minutes instead of seconds for SQLite datetime interval
This commit is contained in:
@@ -76,8 +76,11 @@ func retryBackoff(attempts int64) string {
|
|||||||
delay = 30 * time.Minute
|
delay = 30 * time.Minute
|
||||||
}
|
}
|
||||||
|
|
||||||
seconds := int(delay / time.Second)
|
minutes := int(delay / time.Minute)
|
||||||
return fmt.Sprintf("+%d seconds", seconds)
|
if minutes < 1 {
|
||||||
|
minutes = 1
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("+%d minutes", minutes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Worker) processAnimeFetchRetries(ctx context.Context) {
|
func (w *Worker) processAnimeFetchRetries(ctx context.Context) {
|
||||||
@@ -231,10 +234,12 @@ func (w *Worker) ensureAnimeExistsAndStatusUpdated(ctx context.Context, malID in
|
|||||||
// OR we can explicitly fetch its details to keep sequels up to date.
|
// OR we can explicitly fetch its details to keep sequels up to date.
|
||||||
animeDetails, err := w.client.GetAnimeByID(ctx, malID)
|
animeDetails, err := w.client.GetAnimeByID(ctx, malID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
w.db.UpdateAnimeStatus(ctx, database.UpdateAnimeStatusParams{
|
if err := w.db.UpdateAnimeStatus(ctx, database.UpdateAnimeStatusParams{
|
||||||
Status: sql.NullString{String: animeDetails.Status, Valid: true},
|
Status: sql.NullString{String: animeDetails.Status, Valid: true},
|
||||||
ID: int64(animeDetails.MalID),
|
ID: int64(animeDetails.MalID),
|
||||||
})
|
}); err != nil {
|
||||||
|
log.Printf("worker: failed to update status for anime %d: %v", animeDetails.MalID, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
time.Sleep(400 * time.Millisecond)
|
time.Sleep(400 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user