Ajout de stats pour avoir le nb de sauts par type et par année
This commit is contained in:
@@ -17,6 +17,7 @@ namespace skydiveLogs_api.Domain
|
||||
ForLastMonthByJumpType = new List<Statistic>();
|
||||
ForLastYearByDz = new List<Statistic>();
|
||||
ForLastYearByJumpType = new List<Statistic>();
|
||||
ByYearByJumpType = new List<Statistic>();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -32,6 +33,7 @@ namespace skydiveLogs_api.Domain
|
||||
public IEnumerable<Statistic> ForLastMonthByJumpType { get; set; }
|
||||
public IEnumerable<Statistic> ForLastYearByDz { get; set; }
|
||||
public IEnumerable<Statistic> ForLastYearByJumpType { get; set; }
|
||||
public IEnumerable<Statistic> ByYearByJumpType { get; set; }
|
||||
public int Id { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||
IEnumerable<Statistic> GetStatsForLastYearByDz();
|
||||
|
||||
IEnumerable<Statistic> GetStatsForLastYearByJumpType();
|
||||
|
||||
IEnumerable<Statistic> GetStatsByYearByJumpType();
|
||||
|
||||
void Reset();
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -304,6 +304,34 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
return allStats.ForLastYearByJumpType;
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsByYearByJumpType()
|
||||
{
|
||||
var allStats = GetAllStats();
|
||||
if (!allStats.ByYearByJumpType.Any())
|
||||
{
|
||||
var allJumps = _jumpService.GetAllJumps();
|
||||
var results = new List<Statistic>();
|
||||
|
||||
if (allJumps.Any())
|
||||
{
|
||||
results = allJumps.GroupBy(j => new { j.JumpType.Name, j.JumpDate.Year },
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.Year.ToString(),
|
||||
Label2 = groupby.Name.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
allStats.ByYearByJumpType = results;
|
||||
_userStatsRepository.Update(allStats);
|
||||
}
|
||||
|
||||
return allStats.ByYearByJumpType;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
var resetStats = new UserStats();
|
||||
|
||||
@@ -95,6 +95,15 @@ namespace skydiveLogs_api.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet("ByYearByJumpType")]
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticForChartResp> ByYearByJumpType()
|
||||
{
|
||||
var result = _statsService.GetStatsByYearByJumpType();
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticForChartResp>>(result);
|
||||
}
|
||||
|
||||
[HttpGet("Reset")]
|
||||
[EnableCors]
|
||||
public void Reset()
|
||||
|
||||
Reference in New Issue
Block a user