feat!: Remove `reset_unmatched_scores` under quality score config

pull/201/head
Robert Dailey 1 year ago
parent 982de8806f
commit cd6eda4055

@ -22,6 +22,7 @@ changes you may need to make.
- **BREAKING**: Array-style instances are no longer supported.
- **BREAKING**: Remove deprecated CLI commands: `radarr`, `sonarr`, and `create-config`.
- **BREAKING**: Removed `reset_unmatched_scores` support under quality profile score section.
## [4.4.1] - 2023-04-08

@ -11,101 +11,6 @@ namespace Recyclarr.Cli.Tests.Pipelines.QualityProfile.PipelinePhases;
[Parallelizable(ParallelScope.All)]
public class QualityProfileConfigPhaseTest
{
[Test, AutoMockData]
public void Reset_unmatched_scores_promoted_to_quality_profiles_property_when_no_quality_profiles_in_config(
QualityProfileConfigPhase sut)
{
var config = new RadarrConfiguration
{
CustomFormats = new List<CustomFormatConfig>
{
new()
{
QualityProfiles = new List<QualityProfileScoreConfig>
{
new()
{
Name = "test_profile",
ResetUnmatchedScores = true
}
}
}
}
};
sut.Execute(config);
config.QualityProfiles.Should().BeEquivalentTo(new QualityProfileConfig[]
{
new() {Name = "test_profile", ResetUnmatchedScores = true}
});
}
[Test, AutoMockData]
public void Reset_unmatched_scores_promoted_to_quality_profiles_property_when_quality_profile_in_config(
QualityProfileConfigPhase sut)
{
var config = new RadarrConfiguration
{
QualityProfiles = new[]
{
new QualityProfileConfig
{
Name = "test_profile",
ResetUnmatchedScores = null
}
},
CustomFormats = new List<CustomFormatConfig>
{
new()
{
QualityProfiles = new List<QualityProfileScoreConfig>
{
new()
{
Name = "test_profile",
ResetUnmatchedScores = true
}
}
}
}
};
sut.Execute(config);
config.QualityProfiles.Should().BeEquivalentTo(new QualityProfileConfig[]
{
new() {Name = "test_profile", ResetUnmatchedScores = true}
});
}
[Test, AutoMockData]
public void Reset_unmatched_scores_not_promoted_to_quality_profiles_property_when_false(
QualityProfileConfigPhase sut)
{
var config = new RadarrConfiguration
{
CustomFormats = new List<CustomFormatConfig>
{
new()
{
QualityProfiles = new List<QualityProfileScoreConfig>
{
new()
{
Name = "test_profile",
ResetUnmatchedScores = false
}
}
}
}
};
sut.Execute(config);
config.QualityProfiles.Should().BeEmpty();
}
private static RadarrConfiguration SetupCfs(params CustomFormatConfig[] cfConfigs)
{
return new RadarrConfiguration
@ -262,49 +167,4 @@ public class QualityProfileConfigPhaseTest
NewQp.Processed("test_profile2", (1, 200))
});
}
[Test, AutoMockData]
public void Use_existing_config_quality_profile_when_specified(
[Frozen] ProcessedCustomFormatCache cache,
QualityProfileConfigPhase sut)
{
cache.AddCustomFormats(new[]
{
NewCf.DataWithScore("", "id1", 100, 1)
});
var config = new RadarrConfiguration
{
QualityProfiles = new[]
{
new QualityProfileConfig
{
Name = "test_profile",
ResetUnmatchedScores = true
}
},
CustomFormats = new List<CustomFormatConfig>
{
new()
{
TrashIds = new[] {"id1"},
QualityProfiles = new List<QualityProfileScoreConfig>
{
new()
{
Name = "test_profile",
ResetUnmatchedScores = false // Should be ignored because top-level QP has it set already
}
}
}
}
};
sut.Execute(config);
config.QualityProfiles.Should().BeEquivalentTo(new QualityProfileConfig[]
{
new() {Name = "test_profile", ResetUnmatchedScores = true}
});
}
}

@ -23,8 +23,6 @@ public class QualityProfileConfigPhase
public IReadOnlyCollection<ProcessedQualityProfileData> Execute(IServiceConfiguration config)
{
ProcessLegacyResetUnmatchedScores(config);
// 1. For each group of CFs that has a quality profile specified
// 2. For each quality profile score config in that CF group
// 3. For each CF in the group above, match it to a Guide CF object and pair it with the quality profile config
@ -61,52 +59,6 @@ public class QualityProfileConfigPhase
.ToList();
}
private void ProcessLegacyResetUnmatchedScores(IServiceConfiguration config)
{
// todo: Remove this method later; it is for backward compatibility
var legacyResetUnmatchedScores = config.CustomFormats
.SelectMany(x => x.QualityProfiles)
.Where(x => x.ResetUnmatchedScores is not null)
.ToList();
if (legacyResetUnmatchedScores.Count > 0)
{
_log.Warning(
"DEPRECATION: Support for using `reset_unmatched_scores` under `custom_formats.quality_profiles` " +
"will be removed in a future release. Move it to the top level `quality_profiles` instead");
}
// Propagate the quality_profile version of ResetUnmatchedScores to the top-level quality_profile config.
var profilesThatNeedResetUnmatchedScores = legacyResetUnmatchedScores
.Where(x => x.ResetUnmatchedScores is true)
.Select(x => x.Name)
.Distinct(StringComparer.InvariantCultureIgnoreCase);
var newQualityProfiles = config.QualityProfiles.ToList();
foreach (var profileName in profilesThatNeedResetUnmatchedScores)
{
var match = config.QualityProfiles.FirstOrDefault(x => x.Name.EqualsIgnoreCase(profileName));
if (match is null)
{
_log.Debug(
"Root-level quality profile created to promote reset_unmatched_scores from CF score config: {Name}",
profileName);
newQualityProfiles.Add(new QualityProfileConfig {Name = profileName, ResetUnmatchedScores = true});
}
else if (match.ResetUnmatchedScores is null)
{
_log.Debug(
"Score-based reset_unmatched_scores propagated to existing root-level " +
"quality profile config: {Name}", profileName);
match.ResetUnmatchedScores = true;
}
}
// Down-cast to avoid having to make the property mutable in the interface
((ServiceConfiguration) config).QualityProfiles = newQualityProfiles;
}
private void AddCustomFormatScoreData(
IDictionary<int, int> existingScoreData,
QualityProfileScoreConfig profile,

@ -13,6 +13,9 @@ public static class ConfigDeprecations
"See: https://recyclarr.dev/wiki/upgrade-guide/v5.0/#instances-must-now-be-named";
}
// "DEPRECATION: Support for using `reset_unmatched_scores` under `custom_formats.quality_profiles` " +
// "will be removed in a future release. Move it to the top level `quality_profiles` instead"
return null;
}
}

@ -18,8 +18,7 @@ public abstract record ServiceConfiguration : IServiceConfiguration
public QualityDefinitionConfig? QualityDefinition { get; init; }
// todo: Remove the setter later once ResetUnmatchedScores is removed from custom format quality profiles property
public IReadOnlyCollection<QualityProfileConfig> QualityProfiles { get; set; } =
public IReadOnlyCollection<QualityProfileConfig> QualityProfiles { get; init; } =
Array.Empty<QualityProfileConfig>();
}
@ -37,7 +36,6 @@ public record QualityProfileScoreConfig
{
public string Name { get; init; } = "";
public int? Score { get; init; }
public bool? ResetUnmatchedScores { get; init; }
}
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
@ -49,7 +47,6 @@ public record QualityDefinitionConfig
public record QualityProfileConfig
{
// todo: Remove the setter later once reset_unmatched_scores is not in the cf.quality_profiles property anymore
public bool? ResetUnmatchedScores { get; set; }
public bool? ResetUnmatchedScores { get; init; }
public string Name { get; init; } = "";
}

Loading…
Cancel
Save