< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_SourceFile()100%11100%
get_LineNumber()100%11100%
get_ErrorCode()100%11100%
get_Message()100%11100%

File(s)

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

#LineLine coverage
 1namespace RoleRadar.Application.Tracking.Import;
 2
 403public sealed record TrackerImportRowError(
 164    string SourceFile,
 185    int LineNumber,
 146    string ErrorCode,
 427    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{
 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}