fix(metadata): preserve refresh debt reason masks
This commit is contained in:
@@ -111,7 +111,8 @@ func (l *PGLibraryRefreshItemLister) ListLibraryItems(ctx context.Context, libra
|
||||
OR mi.refresh_failures > 0
|
||||
OR mi.episode_metadata_incomplete = TRUE
|
||||
OR (
|
||||
COALESCE(mi.tmdb_id, '') = ''
|
||||
LOWER(TRIM(COALESCE(mi.status, ''))) = 'matched'
|
||||
AND COALESCE(mi.tmdb_id, '') = ''
|
||||
AND (
|
||||
COALESCE(mi.tvdb_id, '') <> ''
|
||||
OR COALESCE(mi.imdb_id, '') <> ''
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
RefreshDebtReasonEpisodeIncomplete int64 = 1 << iota
|
||||
RefreshDebtReasonStaleProviderID
|
||||
RefreshDebtReasonProviderIDIncomplete
|
||||
RefreshDebtReasonRefreshFailure
|
||||
RefreshDebtReasonCoreMetadataIncomplete
|
||||
RefreshDebtReasonEpisodeIncomplete int64 = 1
|
||||
RefreshDebtReasonStaleProviderID int64 = 2
|
||||
RefreshDebtReasonRefreshFailure int64 = 4
|
||||
RefreshDebtReasonCoreMetadataIncomplete int64 = 8
|
||||
RefreshDebtReasonProviderIDIncomplete int64 = 16
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -67,6 +67,38 @@ func TestRefreshDebtReasonsForItemDoesNotFlagProviderIDIncompleteWithoutAlternat
|
||||
}
|
||||
}
|
||||
|
||||
func TestRefreshDebtReasonMaskValuesAreStable(t *testing.T) {
|
||||
tests := map[string]int64{
|
||||
"episode_incomplete": 1,
|
||||
"stale_provider_id": 2,
|
||||
"refresh_failure": 4,
|
||||
"core_metadata_incomplete": 8,
|
||||
"provider_id_incomplete": 16,
|
||||
}
|
||||
got := map[string]int64{
|
||||
"episode_incomplete": RefreshDebtReasonEpisodeIncomplete,
|
||||
"stale_provider_id": RefreshDebtReasonStaleProviderID,
|
||||
"refresh_failure": RefreshDebtReasonRefreshFailure,
|
||||
"core_metadata_incomplete": RefreshDebtReasonCoreMetadataIncomplete,
|
||||
"provider_id_incomplete": RefreshDebtReasonProviderIDIncomplete,
|
||||
}
|
||||
for name, want := range tests {
|
||||
if got[name] != want {
|
||||
t.Fatalf("%s mask = %d, want %d", name, got[name], want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRefreshDebtPriorityProviderIDIncomplete(t *testing.T) {
|
||||
if got := refreshDebtPriority(RefreshDebtReasonProviderIDIncomplete); got != 240 {
|
||||
t.Fatalf("provider id incomplete priority = %d, want 240", got)
|
||||
}
|
||||
combined := RefreshDebtReasonProviderIDIncomplete | RefreshDebtReasonStaleProviderID
|
||||
if got := refreshDebtPriority(combined); got != 250 {
|
||||
t.Fatalf("combined stale/provider priority = %d, want stale priority 250", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNextRefreshDelayEpisodeSchedule(t *testing.T) {
|
||||
reasonMask := RefreshDebtReasonEpisodeIncomplete
|
||||
cases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user