Split tables for the stats #6
@@ -1,42 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
|
||||||
{
|
|
||||||
public class UserStats
|
|
||||||
{
|
|
||||||
#region Public Constructors
|
|
||||||
|
|
||||||
public UserStats()
|
|
||||||
{
|
|
||||||
ByAircraft = new List<Statistic>();
|
|
||||||
ByDz = new List<Statistic>();
|
|
||||||
ByGear = new List<Statistic>();
|
|
||||||
ByJumpType = new List<Statistic>();
|
|
||||||
ByYear = new List<Statistic>();
|
|
||||||
ForLastMonthByDz = new List<Statistic>();
|
|
||||||
ForLastMonthByJumpType = new List<Statistic>();
|
|
||||||
ForLastYearByDz = new List<Statistic>();
|
|
||||||
ForLastYearByJumpType = new List<Statistic>();
|
|
||||||
ByYearByJumpType = new List<Statistic>();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Public Constructors
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> ByAircraft { get; set; }
|
|
||||||
public IEnumerable<Statistic> ByDz { get; set; }
|
|
||||||
public IEnumerable<Statistic> ByGear { get; set; }
|
|
||||||
public IEnumerable<Statistic> ByJumpType { get; set; }
|
|
||||||
public IEnumerable<Statistic> ByYear { get; set; }
|
|
||||||
public IEnumerable<Statistic> ForLastMonthByDz { get; set; }
|
|
||||||
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; }
|
|
||||||
|
|
||||||
#endregion Public Properties
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsByDzService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsByGearService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsByYearByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsByYearService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsForLastMonthByDzService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsForLastMonthByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsForLastYearByDzService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
|
{
|
||||||
|
public interface IStatsForLastYearByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
IEnumerable<Statistic> GetStats();
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
{
|
{
|
||||||
@@ -9,26 +8,6 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
|
|
||||||
SimpleSummary GetSimpleSummary();
|
SimpleSummary GetSimpleSummary();
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByAircraft();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByDz();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByGear();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByJumpType();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByYear();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastYearByDz();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastYearByJumpType();
|
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByYearByJumpType();
|
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
399
Back/skydiveLogs-api.DomainBusiness/StatsByDzService.cs
Normal file
399
Back/skydiveLogs-api.DomainBusiness/StatsByDzService.cs
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsByDzService : IStatsByDzService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsByDzService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Constructors
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStats()
|
||||||
|
{
|
||||||
|
// var allStats = GetAllStats();
|
||||||
|
// if (!allStats.ByAircraft.Any())
|
||||||
|
// {
|
||||||
|
// var allJumps = _jumpService.GetAllJumps();
|
||||||
|
// var results = new List<Statistic>();
|
||||||
|
|
||||||
|
// if (allJumps.Any())
|
||||||
|
// {
|
||||||
|
// results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
// j => j,
|
||||||
|
// (groupby, jumps) => new Statistic
|
||||||
|
// {
|
||||||
|
// Label = groupby.ToString(),
|
||||||
|
// Nb = jumps.Count()
|
||||||
|
// })];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// allStats.ByAircraft = results;
|
||||||
|
// _userStatsRepository.Update(allStats);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return allStats.ByAircraft;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
396
Back/skydiveLogs-api.DomainBusiness/StatsByGearService.cs
Normal file
396
Back/skydiveLogs-api.DomainBusiness/StatsByGearService.cs
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsByGearService : IStatsByGearService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsByGearService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
396
Back/skydiveLogs-api.DomainBusiness/StatsByJumpTypeService.cs
Normal file
396
Back/skydiveLogs-api.DomainBusiness/StatsByJumpTypeService.cs
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsByJumpTypeService : IStatsByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsByJumpTypeService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsByYearByJumpTypeService : IStatsByYearByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsByYearByJumpTypeService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
396
Back/skydiveLogs-api.DomainBusiness/StatsByYearService.cs
Normal file
396
Back/skydiveLogs-api.DomainBusiness/StatsByYearService.cs
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsByYearService : IStatsByYearService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsByYearService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsForLastMonthByDzService : IStatsForLastMonthByDzService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsForLastMonthByDzService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsForLastMonthByJumpTypeService : IStatsForLastMonthByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsForLastMonthByJumpTypeService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsForLastYearByDzService : IStatsForLastYearByDzService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsForLastYearByDzService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,396 @@
|
|||||||
|
using skydiveLogs_api.Domain;
|
||||||
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
|
{
|
||||||
|
public class StatsForLastYearByJumpTypeService : IStatsForLastYearByJumpTypeService
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public StatsForLastYearByJumpTypeService(IJumpService jumpService,
|
||||||
|
IIdentityService identityService,
|
||||||
|
IStatsByDzRepository statsByDzRepository,
|
||||||
|
IStatsByGearRepository statsByGearRepository,
|
||||||
|
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
||||||
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
||||||
|
IStatsByYearRepository statsByYearRepository,
|
||||||
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
||||||
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
||||||
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
||||||
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
|
{
|
||||||
|
_jumpService = jumpService;
|
||||||
|
_identityService = identityService;
|
||||||
|
_statsByDzRepository = statsByDzRepository;
|
||||||
|
_statsByGearRepository = statsByGearRepository;
|
||||||
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
|
_statsByYearRepository = statsByYearRepository;
|
||||||
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByAircraft.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByAircraft = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByGear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByGear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ByYear.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYear = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastMonthByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
|
results = [.. 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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastMonthByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastMonthByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByDz.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.DropZone.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByDz = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ForLastYearByDz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var allStats = GetAllStats();
|
||||||
|
if (!allStats.ForLastYearByJumpType.Any())
|
||||||
|
{
|
||||||
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
|
if (allJumps.Any())
|
||||||
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
|
.GroupBy(j => j.JumpType.Name,
|
||||||
|
j => j,
|
||||||
|
(groupby, jumps) => new Statistic
|
||||||
|
{
|
||||||
|
Label = groupby.ToString(),
|
||||||
|
Nb = jumps.Count()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ForLastYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
allStats.ByYearByJumpType = results;
|
||||||
|
_userStatsRepository.Update(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats.ByYearByJumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
var resetStats = new UserStats();
|
||||||
|
var myStats = GetAllStats();
|
||||||
|
myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
|
myStats.ByDz = resetStats.ByDz;
|
||||||
|
myStats.ByGear = resetStats.ByGear;
|
||||||
|
myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
|
myStats.ByYear = resetStats.ByYear;
|
||||||
|
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
|
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
|
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
|
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
|
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private UserStats GetAllStats()
|
||||||
|
{
|
||||||
|
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (allStats == null)
|
||||||
|
{
|
||||||
|
allStats = new UserStats
|
||||||
|
{
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
|
};
|
||||||
|
_userStatsRepository.Add(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByDzRepository _statsByDzRepository;
|
||||||
|
private readonly IStatsByGearRepository _statsByGearRepository;
|
||||||
|
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
||||||
|
private readonly IStatsByYearRepository _statsByYearRepository;
|
||||||
|
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
|
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
|
#endregion Private Fields
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
using skydiveLogs_api.DomainService.Repositories;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace skydiveLogs_api.DomainBusiness
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
@@ -10,13 +8,9 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
public StatsService(IJumpService jumpService,
|
public StatsService(IJumpService jumpService)
|
||||||
IUserStatsRepository userStatsRepository,
|
|
||||||
IIdentityService identityService)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
|
||||||
_userStatsRepository = userStatsRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
@@ -43,339 +37,29 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByAircraft()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ByAircraft.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
results = allJumps.GroupBy(j => j.Aircraft.Name,
|
|
||||||
j => j,
|
|
||||||
(groupby, jumps) => new Statistic
|
|
||||||
{
|
|
||||||
Label = groupby.ToString(),
|
|
||||||
Nb = jumps.Count()
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ByAircraft = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ByAircraft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByDz()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ByDz.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
results = allJumps.GroupBy(j => j.DropZone.Name,
|
|
||||||
j => j,
|
|
||||||
(groupby, jumps) => new Statistic
|
|
||||||
{
|
|
||||||
Label = groupby.ToString(),
|
|
||||||
Nb = jumps.Count()
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ByDz = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ByDz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByGear()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ByGear.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
results = allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
|
||||||
j => j,
|
|
||||||
(groupby, jumps) => new Statistic
|
|
||||||
{
|
|
||||||
Label = groupby.ToString(),
|
|
||||||
Nb = jumps.Count()
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ByGear = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ByGear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByJumpType()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ByJumpType.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
results = allJumps.GroupBy(j => j.JumpType.Name,
|
|
||||||
j => j,
|
|
||||||
(groupby, jumps) => new Statistic
|
|
||||||
{
|
|
||||||
Label = groupby.ToString(),
|
|
||||||
Nb = jumps.Count()
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ByJumpType = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ByJumpType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByYear()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ByYear.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
results = allJumps.GroupBy(j => j.JumpDate.Year,
|
|
||||||
j => j,
|
|
||||||
(groupby, jumps) => new Statistic
|
|
||||||
{
|
|
||||||
Label = groupby.ToString(),
|
|
||||||
Nb = jumps.Count()
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ByYear = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ByYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ForLastMonthByDz.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
|
||||||
var monthOfLastJump = lastJump.JumpDate.Month;
|
|
||||||
|
|
||||||
results = 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ForLastMonthByDz = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ForLastMonthByDz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ForLastMonthByJumpType.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
|
||||||
var monthOfLastJump = lastJump.JumpDate.Month;
|
|
||||||
|
|
||||||
results = 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ForLastMonthByJumpType = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ForLastMonthByJumpType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ForLastYearByDz.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
|
||||||
|
|
||||||
results = 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ForLastYearByDz = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats.ForLastYearByDz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
|
||||||
{
|
|
||||||
var allStats = GetAllStats();
|
|
||||||
if (!allStats.ForLastYearByJumpType.Any())
|
|
||||||
{
|
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
|
||||||
var results = new List<Statistic>();
|
|
||||||
|
|
||||||
if (allJumps.Any())
|
|
||||||
{
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
|
||||||
|
|
||||||
results = 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
allStats.ForLastYearByJumpType = results;
|
|
||||||
_userStatsRepository.Update(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
public void Reset()
|
||||||
{
|
{
|
||||||
var resetStats = new UserStats();
|
// var resetStats = new UserStats();
|
||||||
var myStats = GetAllStats();
|
// var myStats = GetAllStats();
|
||||||
myStats.ByAircraft = resetStats.ByAircraft;
|
// myStats.ByAircraft = resetStats.ByAircraft;
|
||||||
myStats.ByDz = resetStats.ByDz;
|
// myStats.ByDz = resetStats.ByDz;
|
||||||
myStats.ByGear = resetStats.ByGear;
|
// myStats.ByGear = resetStats.ByGear;
|
||||||
myStats.ByJumpType = resetStats.ByJumpType;
|
// myStats.ByJumpType = resetStats.ByJumpType;
|
||||||
myStats.ByYear = resetStats.ByYear;
|
// myStats.ByYear = resetStats.ByYear;
|
||||||
myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
// myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||||
myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
// myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||||
myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
// myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||||
myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
// myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||||
myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
// myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||||
|
|
||||||
_userStatsRepository.Update(myStats);
|
// _userStatsRepository.Update(myStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Methods
|
|
||||||
|
|
||||||
private UserStats GetAllStats()
|
|
||||||
{
|
|
||||||
var allStats = _userStatsRepository.GetAll(_identityService.ConnectedUser);
|
|
||||||
if (allStats == null)
|
|
||||||
{
|
|
||||||
allStats = new UserStats
|
|
||||||
{
|
|
||||||
User = _identityService.ConnectedUser
|
|
||||||
};
|
|
||||||
_userStatsRepository.Add(allStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Private Methods
|
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
|
||||||
private readonly IJumpService _jumpService;
|
private readonly IJumpService _jumpService;
|
||||||
private readonly IUserStatsRepository _userStatsRepository;
|
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
using skydiveLogs_api.Domain;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
|
||||||
{
|
|
||||||
public interface IUserStatsRepository : IRepository<UserStats>
|
|
||||||
{
|
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
UserStats GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,13 +32,23 @@ namespace skydiveLogs_api.Ioc
|
|||||||
_services.AddScoped<IDropZoneService, DropZoneService>();
|
_services.AddScoped<IDropZoneService, DropZoneService>();
|
||||||
_services.AddScoped<IJumpService, JumpService>();
|
_services.AddScoped<IJumpService, JumpService>();
|
||||||
_services.AddScoped<IJumpTypeService, JumpTypeService>();
|
_services.AddScoped<IJumpTypeService, JumpTypeService>();
|
||||||
_services.AddScoped<IStatsService, StatsService>();
|
|
||||||
_services.AddScoped<IUserService, UserService>();
|
_services.AddScoped<IUserService, UserService>();
|
||||||
_services.AddScoped<IUserImageService, UserImageService>();
|
_services.AddScoped<IUserImageService, UserImageService>();
|
||||||
_services.AddScoped<IInitDbService, InitDbService>();
|
_services.AddScoped<IInitDbService, InitDbService>();
|
||||||
_services.AddScoped<ITunnelService, TunnelService>();
|
_services.AddScoped<ITunnelService, TunnelService>();
|
||||||
_services.AddScoped<ITunnelFlightService, TunnelFlightService>();
|
_services.AddScoped<ITunnelFlightService, TunnelFlightService>();
|
||||||
|
|
||||||
|
_services.AddScoped<IStatsService, StatsService>();
|
||||||
|
_services.AddScoped<IStatsByDzService, StatsByDzService>();
|
||||||
|
_services.AddScoped<IStatsByGearService, StatsByGearService>();
|
||||||
|
_services.AddScoped<IStatsByJumpTypeService, StatsByJumpTypeService>();
|
||||||
|
_services.AddScoped<IStatsByYearByJumpTypeService, StatsByYearByJumpTypeService>();
|
||||||
|
_services.AddScoped<IStatsByYearService, StatsByYearService>();
|
||||||
|
_services.AddScoped<IStatsForLastMonthByDzService, StatsForLastMonthByDzService>();
|
||||||
|
_services.AddScoped<IStatsForLastMonthByJumpTypeService, StatsForLastMonthByJumpTypeService>();
|
||||||
|
_services.AddScoped<IStatsForLastYearByDzService, StatsForLastYearByDzService>();
|
||||||
|
_services.AddScoped<IStatsForLastYearByJumpTypeService, StatsForLastYearByJumpTypeService>();
|
||||||
|
|
||||||
_services.AddSingleton<ICacheService, CacheService>();
|
_services.AddSingleton<ICacheService, CacheService>();
|
||||||
_services.AddScoped<IIdentityService, IdentityService>();
|
_services.AddScoped<IIdentityService, IdentityService>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user