feat: add salary insights
CI and Deploy / test (push) Successful in 2m41s
CI and Deploy / deploy (push) Successful in 58s

This commit is contained in:
cesnimda
2026-07-31 00:15:38 +02:00
parent af3cf1cdaa
commit 235d22c059
5 changed files with 83 additions and 4 deletions
+24 -2
View File
@@ -85,7 +85,11 @@ namespace JobTrackerApi.Services
j.SavedAt,
j.CompanyId,
CompanyName = j.Company.Name,
CompanySource = j.Company.Source
CompanySource = j.Company.Source,
j.SalaryMin,
j.SalaryMax,
j.SalaryCurrency,
j.SalaryPeriod
})
.ToListAsync(cancellationToken);
@@ -176,6 +180,23 @@ namespace JobTrackerApi.Services
.Select(p => new StageDurationDto(p.Stage, p.MedianDays, p.Count))
.ToList();
var salaryInsights = activeJobs
.Where(j => (j.SalaryMin is not null || j.SalaryMax is not null)
&& !string.IsNullOrWhiteSpace(j.SalaryCurrency)
&& !string.IsNullOrWhiteSpace(j.SalaryPeriod))
.GroupBy(j => new { Currency = j.SalaryCurrency!.ToUpperInvariant(), Period = j.SalaryPeriod!.ToLowerInvariant() })
.Select(g => new SalaryInsightDto(
g.Key.Currency,
g.Key.Period,
g.Count(),
g.Min(j => j.SalaryMin ?? j.SalaryMax!.Value),
g.Max(j => j.SalaryMax ?? j.SalaryMin!.Value),
Math.Round(g.Average(j => ((j.SalaryMin ?? j.SalaryMax!.Value) + (j.SalaryMax ?? j.SalaryMin!.Value)) / 2m), 0)))
.OrderByDescending(x => x.Count)
.ThenBy(x => x.Currency)
.ThenBy(x => x.Period)
.ToList();
return new AnalyticsOverviewDto(
Funnel: funnel,
ResponseRateBySource: responseRateBySource,
@@ -183,7 +204,8 @@ namespace JobTrackerApi.Services
MedianDaysToFirstResponse: medianDays,
TotalResponses: activeJobs.Count(j => j.ResponseReceived || j.ResponseDate is not null),
TotalActive: activeJobs.Count,
TimeInStage: timeInStage
TimeInStage: timeInStage,
SalaryInsights: salaryInsights
);
}
}