Reviewed-on: #6 Co-authored-by: sandre <perso@sebastienandre.com> Co-committed-by: sandre <perso@sebastienandre.com>
194 lines
6.8 KiB
C#
194 lines
6.8 KiB
C#
using skydiveLogs_api.Domain;
|
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace skydiveLogs_api.DomainBusiness
|
|
{
|
|
public class StatsService : IStatsService
|
|
{
|
|
#region Public Constructors
|
|
|
|
public StatsService(IJumpService jumpService,
|
|
IStatsByAircraftService statsByAircraftService,
|
|
IStatsByDzService statsByDzService,
|
|
IStatsByGearService statsByGearService,
|
|
IStatsByJumpTypeService statsByJumpTypeService,
|
|
IStatsByYearByJumpTypeService statsByYearByJumpTypeService,
|
|
IStatsByYearService statsByYearService,
|
|
IStatsForLastMonthByDzService statsForLastMonthByDzService,
|
|
IStatsForLastMonthByJumpTypeService statsForLastMonthByJumpTypeService,
|
|
IStatsForLastYearByDzService statsForLastYearByDzService,
|
|
IStatsForLastYearByJumpTypeService statsForLastYearByJumpTypeService)
|
|
{
|
|
_jumpService = jumpService;
|
|
_statsByAircraftService = statsByAircraftService;
|
|
_statsByDzService = statsByDzService;
|
|
_statsByGearService = statsByGearService;
|
|
_statsByJumpTypeService = statsByJumpTypeService;
|
|
_statsByYearByJumpTypeService = statsByYearByJumpTypeService;
|
|
_statsByYearService = statsByYearService;
|
|
_statsForLastMonthByDzService = statsForLastMonthByDzService;
|
|
_statsForLastMonthByJumpTypeService = statsForLastMonthByJumpTypeService;
|
|
_statsForLastYearByDzService = statsForLastYearByDzService;
|
|
_statsForLastYearByJumpTypeService = statsForLastYearByJumpTypeService;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
public SimpleSummary GetSimpleSummary()
|
|
{
|
|
var allJumps = _jumpService.GetAllJumps();
|
|
var results = new SimpleSummary();
|
|
|
|
if (allJumps.Any())
|
|
{
|
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
|
|
|
results = new SimpleSummary
|
|
{
|
|
LastJump = lastJump,
|
|
TotalJumps = allJumps.Count(),
|
|
TotalCutaways = allJumps.Where(j => j.WithCutaway).Count()
|
|
};
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
_statsByAircraftService.Reset();
|
|
_statsByDzService.Reset();
|
|
_statsByGearService.Reset();
|
|
_statsByJumpTypeService.Reset();
|
|
_statsByYearByJumpTypeService.Reset();
|
|
_statsByYearService.Reset();
|
|
_statsForLastMonthByDzService.Reset();
|
|
_statsForLastMonthByJumpTypeService.Reset();
|
|
_statsForLastYearByDzService.Reset();
|
|
_statsForLastYearByJumpTypeService.Reset();
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsByAircraft()
|
|
{
|
|
var tmp = _statsByAircraftService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.Aircraft,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsByDz()
|
|
{
|
|
var tmp = _statsByDzService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.DropZone,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsByGear()
|
|
{
|
|
var tmp = _statsByGearService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.Gear,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
|
{
|
|
var tmp = _statsByJumpTypeService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.JumpType,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsByYear()
|
|
{
|
|
var tmp = _statsByYearService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.Year,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
|
{
|
|
var tmp = _statsForLastMonthByDzService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.DropZone,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
|
{
|
|
var tmp = _statsForLastMonthByJumpTypeService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.JumpType,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
|
{
|
|
var tmp = _statsForLastYearByDzService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.DropZone,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
|
{
|
|
var tmp = _statsForLastYearByJumpTypeService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.JumpType,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
public IEnumerable<Statistic> GetStatsByYearByJumpType()
|
|
{
|
|
var tmp = _statsByYearByJumpTypeService.GetStats();
|
|
return [.. tmp.Select(a => new Statistic
|
|
{
|
|
Label = a.Year,
|
|
Label2 = a.JumpType,
|
|
Nb = a.Nb
|
|
})];
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private readonly IJumpService _jumpService;
|
|
private readonly IStatsByAircraftService _statsByAircraftService;
|
|
private readonly IStatsByDzService _statsByDzService;
|
|
private readonly IStatsByGearService _statsByGearService;
|
|
private readonly IStatsByJumpTypeService _statsByJumpTypeService;
|
|
private readonly IStatsByYearByJumpTypeService _statsByYearByJumpTypeService;
|
|
private readonly IStatsByYearService _statsByYearService;
|
|
private readonly IStatsForLastMonthByDzService _statsForLastMonthByDzService;
|
|
private readonly IStatsForLastMonthByJumpTypeService _statsForLastMonthByJumpTypeService;
|
|
private readonly IStatsForLastYearByDzService _statsForLastYearByDzService;
|
|
private readonly IStatsForLastYearByJumpTypeService _statsForLastYearByJumpTypeService;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |