< Summary

Information
Class: RoleRadar.Application.Tracking.Import.FileReconciliationSummary
Assembly: RoleRadar.Application
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Application/Tracking/Import/TrackerImportSummary.cs
Line coverage
91%
Covered lines: 22
Uncovered lines: 2
Coverable lines: 24
Total lines: 169
Line coverage: 91.6%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_FileName()100%11100%
get_IsAbsent()100%11100%
get_Read()100%11100%
get_Created()100%11100%
get_Updated()100%11100%
get_Unchanged()100%11100%
get_Errored()100%11100%
get_SkippedByReason()100%11100%
get_UnchangedByReason()100%11100%
get_TotalSkipped()100%11100%
get_TotalAccountedFor()100%210%
RecordRead()100%11100%
RecordCreated()100%11100%
RecordUpdated()100%210%
RecordErrored()100%11100%
RecordUnchanged(...)100%22100%
RecordSkipped(...)100%11100%

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{
 42211    public required string FileName { get; init; }
 36612    public bool IsAbsent { get; set; }
 89813    public int Read { get; set; }
 70014    public int Created { get; set; }
 7215    public int Updated { get; set; }
 22216    public int Unchanged { get; set; }
 17017    public int Errored { get; set; }
 40218    public Dictionary<string, int> SkippedByReason { get; } = new(StringComparer.OrdinalIgnoreCase);
 35419    public Dictionary<string, int> UnchangedByReason { get; } = new(StringComparer.OrdinalIgnoreCase);
 20
 7421    public int TotalSkipped => SkippedByReason.Values.Sum();
 022    public int TotalAccountedFor => Created + Updated + Unchanged + TotalSkipped + Errored;
 23
 40024    public void RecordRead() => Read++;
 30425    public void RecordCreated() => Created++;
 026    public void RecordUpdated() => Updated++;
 4027    public void RecordErrored() => Errored++;
 28
 29    public void RecordUnchanged(string? reason = null)
 30    {
 6831        Unchanged++;
 6832        if (!string.IsNullOrWhiteSpace(reason))
 33        {
 2034            UnchangedByReason.TryGetValue(reason, out var count);
 2035            UnchangedByReason[reason] = count + 1;
 36        }
 6837    }
 38
 39    public void RecordSkipped(string reason)
 40    {
 841        ArgumentException.ThrowIfNullOrWhiteSpace(reason);
 842        SkippedByReason.TryGetValue(reason, out var count);
 843        SkippedByReason[reason] = count + 1;
 844    }
 45}
 46
 47public sealed class TrackerImportSummary
 48{
 49    public bool IsDryRun { get; set; }
 50    public int CompaniesCreated { get; set; }
 51    public int CompaniesUpdated { get; set; }
 52    public int CompaniesUnchanged { get; set; }
 53    public int PostingsCreated { get; set; }
 54    public int PostingsUpdated { get; set; }
 55    public int PostingsUnchanged { get; set; }
 56    public int ApplicationsCreated { get; set; }
 57    public int ApplicationsUnchanged { get; set; }
 58    public int StandaloneNotesCreated { get; set; }
 59    public int ScreeningNotesCreated { get; set; }
 60    public int CriteriaCreated { get; set; }
 61    public int SignalsCreated { get; set; }
 62    public int MappedToEventNotes { get; set; }
 63    public int ResumeVariantsDefaulted { get; set; }
 64    public int DatesDefaulted { get; set; }
 65    public int DatesInferred { get; set; }
 66    public int DatesFlagged { get; set; }
 67    public int CultureTruncations { get; set; }
 68    public int CultureUnmapped { get; set; }
 69    public int UnclaimedAppliedPostings { get; set; }
 70
 71    public Dictionary<string, FileReconciliationSummary> FileReconciliations { get; } = new(StringComparer.OrdinalIgnore
 72
 73    public FileReconciliationSummary GetOrCreateFileReconciliation(string fileName)
 74    {
 75        ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
 76        if (!FileReconciliations.TryGetValue(fileName, out var recon))
 77        {
 78            recon = new FileReconciliationSummary { FileName = fileName };
 79            FileReconciliations[fileName] = recon;
 80        }
 81        return recon;
 82    }
 83
 84    public Dictionary<string, int> UnmappedValues { get; } = new(StringComparer.OrdinalIgnoreCase);
 85    public Dictionary<string, List<string>> UnmappedValueSamples { get; } = new(StringComparer.OrdinalIgnoreCase);
 86
 87    public void RecordUnmappedValue(string fieldName, string? rawValue)
 88    {
 89        ArgumentException.ThrowIfNullOrWhiteSpace(fieldName);
 90        UnmappedValues.TryGetValue(fieldName, out var count);
 91        UnmappedValues[fieldName] = count + 1;
 92
 93        if (string.Equals(fieldName, "culture_level", StringComparison.OrdinalIgnoreCase))
 94        {
 95            CultureUnmapped++;
 96        }
 97
 98        if (!string.IsNullOrWhiteSpace(rawValue))
 99        {
 100            if (!UnmappedValueSamples.TryGetValue(fieldName, out var list))
 101            {
 102                list = new List<string>();
 103                UnmappedValueSamples[fieldName] = list;
 104            }
 105
 106            if (!list.Contains(rawValue) && list.Count < 50)
 107            {
 108                list.Add(rawValue);
 109            }
 110        }
 111    }
 112
 113    public Dictionary<string, int> FieldTruncations { get; } = new(StringComparer.OrdinalIgnoreCase);
 114
 115    public void RecordFieldTruncation(string fieldName)
 116    {
 117        ArgumentException.ThrowIfNullOrWhiteSpace(fieldName);
 118        FieldTruncations.TryGetValue(fieldName, out var count);
 119        FieldTruncations[fieldName] = count + 1;
 120        if (string.Equals(fieldName, "culture_summary", StringComparison.OrdinalIgnoreCase))
 121        {
 122            CultureTruncations++;
 123        }
 124    }
 125
 126    public List<string> AutoCreatedCompanies { get; } = new();
 127    public List<string> UnclaimedAppliedPostingTitles { get; } = new();
 128    public List<string> PeopleDetected { get; } = new();
 129    public List<TrackerImportRowError> Errors { get; } = new();
 130
 131    public Dictionary<string, int> DispositionHistogram { get; } = new(StringComparer.OrdinalIgnoreCase);
 132
 133    public Dictionary<string, Dictionary<string, int>> SourceFieldNonEmptyCounts { get; } = new(StringComparer.OrdinalIg
 134
 135    public void RecordFieldRead(string fileName, string fieldName, bool isNonEmpty)
 136    {
 137        ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
 138        ArgumentException.ThrowIfNullOrWhiteSpace(fieldName);
 139
 140        if (!SourceFieldNonEmptyCounts.TryGetValue(fileName, out var fieldCounts))
 141        {
 142            fieldCounts = new(StringComparer.OrdinalIgnoreCase);
 143            SourceFieldNonEmptyCounts[fileName] = fieldCounts;
 144        }
 145
 146        fieldCounts.TryGetValue(fieldName, out var currentCount);
 147        fieldCounts[fieldName] = isNonEmpty ? currentCount + 1 : currentCount;
 148    }
 149
 150    public int GetSourceFieldNonEmptyCount(string fileName, string fieldName)
 151    {
 152        if (SourceFieldNonEmptyCounts.TryGetValue(fileName, out var fieldCounts) &&
 153            fieldCounts.TryGetValue(fieldName, out var count))
 154        {
 155            return count;
 156        }
 157        return 0;
 158    }
 159
 160    public bool IsIdempotentNoOp =>
 161        CompaniesCreated == 0 &&
 162        PostingsCreated == 0 &&
 163        ApplicationsCreated == 0 &&
 164        StandaloneNotesCreated == 0 &&
 165        ScreeningNotesCreated == 0 &&
 166        CriteriaCreated == 0 &&
 167        SignalsCreated == 0 &&
 168        Errors.Count == 0;
 169}