Add controler actions to return stats for
the current season
This commit is contained in:
@@ -14,5 +14,13 @@ namespace skydiveLogs_api.Business.Interface
|
||||
IEnumerable<Statistic> GetStatsByGear();
|
||||
|
||||
IEnumerable<Statistic> GetStatsByYear();
|
||||
|
||||
IEnumerable<Statistic> GetStatsForLastYearByDz();
|
||||
|
||||
IEnumerable<Statistic> GetStatsForLastYearByJumpType();
|
||||
|
||||
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
||||
|
||||
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,80 @@ namespace skydiveLogs_api.Business
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||
|
||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||
.GroupBy(j => j.DropZone.Name,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||
|
||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||
.GroupBy(j => j.JumpType.Name,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||
|
||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
||||
.GroupBy(j => j.DropZone.Name,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||
|
||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
||||
.GroupBy(j => j.JumpType.Name,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private readonly IJumpRepository _jumpRepository;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user