|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
using Common.Extensions;
|
|
|
|
using TrashLib.Services.CustomFormat.Models;
|
|
|
|
using TrashLib.Services.CustomFormat.Models;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TrashLib.Services.CustomFormat.Processors.GuideSteps;
|
|
|
|
namespace TrashLib.Services.CustomFormat.Processors.GuideSteps;
|
|
|
@ -6,12 +7,15 @@ internal class QualityProfileStep : IQualityProfileStep
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly Dictionary<string, QualityProfileCustomFormatScoreMapping> _profileScores = new();
|
|
|
|
private readonly Dictionary<string, QualityProfileCustomFormatScoreMapping> _profileScores = new();
|
|
|
|
private readonly List<(string name, string trashId, string profileName)> _customFormatsWithoutScore = new();
|
|
|
|
private readonly List<(string name, string trashId, string profileName)> _customFormatsWithoutScore = new();
|
|
|
|
|
|
|
|
private readonly Dictionary<string, Dictionary<string, HashSet<int>>> _duplicateScores = new();
|
|
|
|
|
|
|
|
|
|
|
|
public IDictionary<string, QualityProfileCustomFormatScoreMapping> ProfileScores => _profileScores;
|
|
|
|
public IDictionary<string, QualityProfileCustomFormatScoreMapping> ProfileScores => _profileScores;
|
|
|
|
|
|
|
|
|
|
|
|
public IReadOnlyCollection<(string name, string trashId, string profileName)> CustomFormatsWithoutScore
|
|
|
|
public IReadOnlyCollection<(string name, string trashId, string profileName)> CustomFormatsWithoutScore
|
|
|
|
=> _customFormatsWithoutScore;
|
|
|
|
=> _customFormatsWithoutScore;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IReadOnlyDictionary<string, Dictionary<string, HashSet<int>>> DuplicateScores => _duplicateScores;
|
|
|
|
|
|
|
|
|
|
|
|
public void Process(IEnumerable<ProcessedConfigData> configData)
|
|
|
|
public void Process(IEnumerable<ProcessedConfigData> configData)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var config in configData)
|
|
|
|
foreach (var config in configData)
|
|
|
@ -46,6 +50,15 @@ internal class QualityProfileStep : IQualityProfileStep
|
|
|
|
ProfileScores[profile.Name] = mapping;
|
|
|
|
ProfileScores[profile.Name] = mapping;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if this score was specified multiple times for the same profile. For each duplicate, we record
|
|
|
|
|
|
|
|
// the score of the second and onward occurrences for logging/reporting purposes.
|
|
|
|
|
|
|
|
var dupe = mapping.Mapping.FirstOrDefault(x => x.CustomFormat.TrashId.EqualsIgnoreCase(cf.TrashId));
|
|
|
|
|
|
|
|
if (dupe is not null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_duplicateScores.GetOrCreate(profile.Name).GetOrCreate(cf.TrashId).Add(scoreToUse.Value);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mapping.Mapping.Add(new FormatMappingEntry(cf, scoreToUse.Value));
|
|
|
|
mapping.Mapping.Add(new FormatMappingEntry(cf, scoreToUse.Value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|