feat: add salary insights
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user