< Summary

Information
Class: RoleRadar.Application.Tracking.Import.TrackerImportSummary
Assembly: RoleRadar.Application
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Application/Tracking/Import/TrackerImportSummary.cs
Line coverage
100%
Covered lines: 74
Uncovered lines: 0
Coverable lines: 74
Total lines: 169
Line coverage: 100%
Branch coverage
75%
Covered branches: 27
Total branches: 36
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/roleradar/roleradar/src/RoleRadar.Application/Tracking/Import/TrackerImportSummary.cs

#LineLine coverage
 1namespace RoleRadar.Application.Tracking.Import;
 2
 3public sealed record TrackerImportRowError(
 4    string SourceFile,
 5    int LineNumber,
 6    string ErrorCode,
 7    string Message);
 8
 9public sealed class FileReconciliationSummary
 10{
 11    public required string FileName { get; init; }
 12    public bool IsAbsent { get; set; }
 13    public int Read { get; set; }
 14    public int Created { get; set; }
 15    public int Updated { get; set; }
 16    public int Unchanged { get; set; }
 17    public int Errored { get; set; }
 18    public Dictionary<string, int> SkippedByReason { get; } = new(StringComparer.OrdinalIgnoreCase);
 19    public Dictionary<string, int> UnchangedByReason { get; } = new(StringComparer.OrdinalIgnoreCase);
 20
 21    public int TotalSkipped => SkippedByReason.Values.Sum();
 22    public int TotalAccountedFor => Created + Updated + Unchanged + TotalSkipped + Errored;
 23
 24    public void RecordRead() => Read++;
 25    public void RecordCreated() => Created++;
 26    public void RecordUpdated() => Updated++;
 27    public void RecordErrored() => Errored++;
 28
 29    public void RecordUnchanged(string? reason = null)
 30    {
 31        Unchanged++;
 32        if (!string.IsNullOrWhiteSpace(reason))
 33        {
 34            UnchangedByReason.TryGetValue(reason, out var count);
 35            UnchangedByReason[reason] = count + 1;
 36        }
 37    }
 38
 39    public void RecordSkipped(string reason)
 40    {
 41        ArgumentException.ThrowIfNullOrWhiteSpace(reason);
 42        SkippedByReason.TryGetValue(reason, out var count);
 43        SkippedByReason[reason] = count + 1;
 44    }
 45}
 46
 47public sealed class TrackerImportSummary
 48{
 6449    public bool IsDryRun { get; set; }
 28050    public int CompaniesCreated { get; set; }
 1451    public int CompaniesUpdated { get; set; }
 4252    public int CompaniesUnchanged { get; set; }
 42653    public int PostingsCreated { get; set; }
 8254    public int PostingsUpdated { get; set; }
 12255    public int PostingsUnchanged { get; set; }
 12856    public int ApplicationsCreated { get; set; }
 1257    public int ApplicationsUnchanged { get; set; }
 8058    public int StandaloneNotesCreated { get; set; }
 24659    public int ScreeningNotesCreated { get; set; }
 23260    public int CriteriaCreated { get; set; }
 25261    public int SignalsCreated { get; set; }
 10862    public int MappedToEventNotes { get; set; }
 7063    public int ResumeVariantsDefaulted { get; set; }
 13864    public int DatesDefaulted { get; set; }
 11865    public int DatesInferred { get; set; }
 6666    public int DatesFlagged { get; set; }
 2867    public int CultureTruncations { get; set; }
 1268    public int CultureUnmapped { get; set; }
 12269    public int UnclaimedAppliedPostings { get; set; }
 70
 105271    public Dictionary<string, FileReconciliationSummary> FileReconciliations { get; } = new(StringComparer.OrdinalIgnore
 72
 73    public FileReconciliationSummary GetOrCreateFileReconciliation(string fileName)
 74    {
 50875        ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
 50876        if (!FileReconciliations.TryGetValue(fileName, out var recon))
 77        {
 30278            recon = new FileReconciliationSummary { FileName = fileName };
 30279            FileReconciliations[fileName] = recon;
 80        }
 50881        return recon;
 82    }
 83
 56684    public Dictionary<string, int> UnmappedValues { get; } = new(StringComparer.OrdinalIgnoreCase);
 45085    public Dictionary<string, List<string>> UnmappedValueSamples { get; } = new(StringComparer.OrdinalIgnoreCase);
 86
 87    public void RecordUnmappedValue(string fieldName, string? rawValue)
 88    {
 16689        ArgumentException.ThrowIfNullOrWhiteSpace(fieldName);
 16690        UnmappedValues.TryGetValue(fieldName, out var count);
 16691        UnmappedValues[fieldName] = count + 1;
 92
 16693        if (string.Equals(fieldName, "culture_level", StringComparison.OrdinalIgnoreCase))
 94        {
 295            CultureUnmapped++;
 96        }
 97
 16698        if (!string.IsNullOrWhiteSpace(rawValue))
 99        {
 166100            if (!UnmappedValueSamples.TryGetValue(fieldName, out var list))
 101            {
 96102                list = new List<string>();
 96103                UnmappedValueSamples[fieldName] = list;
 104            }
 105
 166106            if (!list.Contains(rawValue) && list.Count < 50)
 107            {
 100108                list.Add(rawValue);
 109            }
 110        }
 166111    }
 112
 336113    public Dictionary<string, int> FieldTruncations { get; } = new(StringComparer.OrdinalIgnoreCase);
 114
 115    public void RecordFieldTruncation(string fieldName)
 116    {
 46117        ArgumentException.ThrowIfNullOrWhiteSpace(fieldName);
 46118        FieldTruncations.TryGetValue(fieldName, out var count);
 46119        FieldTruncations[fieldName] = count + 1;
 46120        if (string.Equals(fieldName, "culture_summary", StringComparison.OrdinalIgnoreCase))
 121        {
 8122            CultureTruncations++;
 123        }
 46124    }
 125
 272126    public List<string> AutoCreatedCompanies { get; } = new();
 290127    public List<string> UnclaimedAppliedPostingTitles { get; } = new();
 210128    public List<string> PeopleDetected { get; } = new();
 276129    public List<TrackerImportRowError> Errors { get; } = new();
 130
 484131    public Dictionary<string, int> DispositionHistogram { get; } = new(StringComparer.OrdinalIgnoreCase);
 132
 7070133    public Dictionary<string, Dictionary<string, int>> SourceFieldNonEmptyCounts { get; } = new(StringComparer.OrdinalIg
 134
 135    public void RecordFieldRead(string fileName, string fieldName, bool isNonEmpty)
 136    {
 5822137        ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
 5822138        ArgumentException.ThrowIfNullOrWhiteSpace(fieldName);
 139
 5822140        if (!SourceFieldNonEmptyCounts.TryGetValue(fileName, out var fieldCounts))
 141        {
 214142            fieldCounts = new(StringComparer.OrdinalIgnoreCase);
 214143            SourceFieldNonEmptyCounts[fileName] = fieldCounts;
 144        }
 145
 5822146        fieldCounts.TryGetValue(fieldName, out var currentCount);
 5822147        fieldCounts[fieldName] = isNonEmpty ? currentCount + 1 : currentCount;
 5822148    }
 149
 150    public int GetSourceFieldNonEmptyCount(string fileName, string fieldName)
 151    {
 850152        if (SourceFieldNonEmptyCounts.TryGetValue(fileName, out var fieldCounts) &&
 850153            fieldCounts.TryGetValue(fieldName, out var count))
 154        {
 550155            return count;
 156        }
 300157        return 0;
 158    }
 159
 160    public bool IsIdempotentNoOp =>
 6161        CompaniesCreated == 0 &&
 6162        PostingsCreated == 0 &&
 6163        ApplicationsCreated == 0 &&
 6164        StandaloneNotesCreated == 0 &&
 6165        ScreeningNotesCreated == 0 &&
 6166        CriteriaCreated == 0 &&
 6167        SignalsCreated == 0 &&
 6168        Errors.Count == 0;
 169}