Split tables for the stats #6
@@ -1,10 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
namespace skydiveLogs_api.Domain
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
|
||||||
{
|
{
|
||||||
public class StatsByAircraft
|
public class StatsByAircraft
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string Aircraft { get; set; }
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsByDz
|
public class StatsByDz
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string DropZone { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsByGear
|
public class StatsByGear
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string Gear { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsByJumpType
|
public class StatsByJumpType
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string JumpType { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsByYear
|
public class StatsByYear
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string Year { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ namespace skydiveLogs_api.Domain
|
|||||||
{
|
{
|
||||||
public class StatsByYearByJumpType
|
public class StatsByYearByJumpType
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string Year { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
public string JumpType { get; set; }
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsForLastMonthByDz
|
public class StatsForLastMonthByDz
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string DropZone { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsForLastMonthByJumpType
|
public class StatsForLastMonthByJumpType
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string JumpType { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsForLastYearByDz
|
public class StatsForLastYearByDz
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string DropZone { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Domain
|
namespace skydiveLogs_api.Domain
|
||||||
{
|
{
|
||||||
public class StatsForLastYearByJumpType
|
public class StatsForLastYearByJumpType
|
||||||
{
|
{
|
||||||
public string Label { get; set; }
|
public string JumpType { get; set; }
|
||||||
|
|
||||||
public string Label2 { get; set; }
|
|
||||||
|
|
||||||
public int Nb { get; set; }
|
public int Nb { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsByDz> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsByGear> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsByJumpType> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsByYearByJumpType> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
public interface IStatsByYearService
|
public interface IStatsByYearService
|
||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsByYear> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsForLastMonthByDz> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsForLastMonthByJumpType> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsForLastYearByDz> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStats();
|
IEnumerable<StatsForLastYearByJumpType> GetStats();
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||||
{
|
{
|
||||||
@@ -8,6 +9,26 @@ 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
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainBusiness
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
{
|
{
|
||||||
public class StatsByByAircraftService : IStatsByAircraftService
|
public class StatsByAircraftService : IStatsByAircraftService
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
public StatsByByAircraftService(IJumpService jumpService,
|
public StatsByAircraftService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByAircraftRepository statsByAircraftRepository)
|
IStatsByAircraftRepository statsByAircraftRepository)
|
||||||
{
|
{
|
||||||
@@ -33,11 +33,11 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
if (allJumps.Any())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
results = [.. allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new StatsByAircraft
|
(groupby, jumps) => new StatsByAircraft
|
||||||
{
|
{
|
||||||
Label = groupby.ToString(),
|
Aircraft = groupby.ToString(),
|
||||||
Nb = jumps.Count(),
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
})];
|
})];
|
||||||
|
|||||||
@@ -23,370 +23,39 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStats()
|
public IEnumerable<StatsByDz> GetStats()
|
||||||
{
|
{
|
||||||
// var allStats = GetAllStats();
|
var allStats = _statsByDzRepository.GetAll(_identityService.ConnectedUser);
|
||||||
// if (!allStats.ByAircraft.Any())
|
if (!allStats.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 allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsByDz>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsByDz
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
DropZone = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsByDzRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsByDzRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
|
|||||||
@@ -12,384 +12,56 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsByGearService(IJumpService jumpService,
|
public StatsByGearService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
IStatsByGearRepository statsByGearRepository)
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
_statsByGearRepository = statsByGearRepository;
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
|
||||||
_statsByYearRepository = statsByYearRepository;
|
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsByGear> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsByGearRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsByGear>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
results = [.. allJumps.GroupBy(j => $"{j.Gear.Name} / {j.Gear.MainCanopy}",
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsByGear
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
Gear = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsByGearRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsByGearRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
private readonly IJumpService _jumpService;
|
||||||
private readonly IStatsByDzRepository _statsByDzRepository;
|
|
||||||
private readonly IStatsByGearRepository _statsByGearRepository;
|
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
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,384 +12,56 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsByJumpTypeService(IJumpService jumpService,
|
public StatsByJumpTypeService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
IStatsByJumpTypeRepository statsByJumpTypeRepository)
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
|
||||||
_statsByYearRepository = statsByYearRepository;
|
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsByJumpType> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsByJumpType>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
results = [.. allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsByJumpType
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
JumpType = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsByJumpTypeRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsByJumpTypeRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
private readonly IJumpService _jumpService;
|
||||||
private readonly IStatsByDzRepository _statsByDzRepository;
|
|
||||||
private readonly IStatsByGearRepository _statsByGearRepository;
|
|
||||||
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
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
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,384 +12,57 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsByYearByJumpTypeService(IJumpService jumpService,
|
public StatsByYearByJumpTypeService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository)
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
||||||
_statsByYearRepository = statsByYearRepository;
|
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsByYearByJumpType> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsByYearByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsByYearByJumpType>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
results = [.. allJumps.GroupBy(j => new { j.JumpType.Name, j.JumpDate.Year },
|
results = [.. allJumps.GroupBy(j => new { j.JumpType.Name, j.JumpDate.Year },
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsByYearByJumpType
|
||||||
{
|
{
|
||||||
Label = groupby.Year.ToString(),
|
Year = groupby.Year.ToString(),
|
||||||
Label2 = groupby.Name.ToString(),
|
JumpType = groupby.Name.ToString(),
|
||||||
Nb = jumps.Count()
|
Nb = jumps.Count(),
|
||||||
|
User = _identityService.ConnectedUser
|
||||||
})];
|
})];
|
||||||
}
|
}
|
||||||
|
|
||||||
allStats.ByYearByJumpType = results;
|
_statsByYearByJumpTypeRepository.Add(results);
|
||||||
_userStatsRepository.Update(allStats);
|
return results;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsByYearByJumpTypeRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
private readonly IJumpService _jumpService;
|
||||||
private readonly IStatsByDzRepository _statsByDzRepository;
|
|
||||||
private readonly IStatsByGearRepository _statsByGearRepository;
|
|
||||||
private readonly IStatsByJumpTypeRepository _statsByJumpTypeRepository;
|
|
||||||
private readonly IStatsByYearByJumpTypeRepository _statsByYearByJumpTypeRepository;
|
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
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,384 +12,56 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsByYearService(IJumpService jumpService,
|
public StatsByYearService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
IStatsByYearRepository statsByYearRepository)
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
|
||||||
_statsByYearRepository = statsByYearRepository;
|
_statsByYearRepository = statsByYearRepository;
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsByYear> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsByYearRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsByYear>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
results = [.. allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsByYear
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
Year = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsByYearRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsByYearRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
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 IStatsByYearRepository _statsByYearRepository;
|
||||||
private readonly IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
|
||||||
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
|
||||||
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
|
||||||
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,190 +12,24 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsForLastMonthByDzService(IJumpService jumpService,
|
public StatsForLastMonthByDzService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository)
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
|
||||||
_statsByYearRepository = statsByYearRepository;
|
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsForLastMonthByDz> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsForLastMonthByDzRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsForLastMonthByDz>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
@@ -206,190 +40,33 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
||||||
.GroupBy(j => j.DropZone.Name,
|
.GroupBy(j => j.DropZone.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsForLastMonthByDz
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
DropZone = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsForLastMonthByDzRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsForLastMonthByDzRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
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 IStatsForLastMonthByDzRepository _statsForLastMonthByDzRepository;
|
||||||
private readonly IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
|
||||||
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
|
||||||
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,221 +12,24 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsForLastMonthByJumpTypeService(IJumpService jumpService,
|
public StatsForLastMonthByJumpTypeService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository)
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
|
||||||
_statsByYearRepository = statsByYearRepository;
|
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsForLastMonthByJumpType> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsForLastMonthByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsForLastMonthByJumpType>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
@@ -237,159 +40,33 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
||||||
.GroupBy(j => j.JumpType.Name,
|
.GroupBy(j => j.JumpType.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsForLastMonthByJumpType
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
JumpType = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsForLastMonthByJumpTypeRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsForLastMonthByJumpTypeRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
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 IStatsForLastMonthByJumpTypeRepository _statsForLastMonthByJumpTypeRepository;
|
||||||
private readonly IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
|
||||||
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,252 +12,24 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsForLastYearByDzService(IJumpService jumpService,
|
public StatsForLastYearByDzService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
IStatsForLastYearByDzRepository statsForLastYearByDzRepository)
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
|
||||||
_statsByYearRepository = statsByYearRepository;
|
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsForLastYearByDz> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsForLastYearByDzRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsForLastYearByDz>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
@@ -267,129 +39,33 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
.GroupBy(j => j.DropZone.Name,
|
.GroupBy(j => j.DropZone.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsForLastYearByDz
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
DropZone = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsForLastYearByDzRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsForLastYearByDzRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
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 IStatsForLastYearByDzRepository _statsForLastYearByDzRepository;
|
||||||
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,26 +12,10 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public StatsForLastYearByJumpTypeService(IJumpService jumpService,
|
public StatsForLastYearByJumpTypeService(IJumpService jumpService,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService,
|
||||||
IStatsByDzRepository statsByDzRepository,
|
|
||||||
IStatsByGearRepository statsByGearRepository,
|
|
||||||
IStatsByJumpTypeRepository statsByJumpTypeRepository,
|
|
||||||
IStatsByYearByJumpTypeRepository statsByYearByJumpTypeRepository,
|
|
||||||
IStatsByYearRepository statsByYearRepository,
|
|
||||||
IStatsForLastMonthByDzRepository statsForLastMonthByDzRepository,
|
|
||||||
IStatsForLastMonthByJumpTypeRepository statsForLastMonthByJumpTypeRepository,
|
|
||||||
IStatsForLastYearByDzRepository statsForLastYearByDzRepository,
|
|
||||||
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
IStatsForLastYearByJumpTypeRepository statsForLastYearByJumpTypeRepository)
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsByDzRepository = statsByDzRepository;
|
|
||||||
_statsByGearRepository = statsByGearRepository;
|
|
||||||
_statsByJumpTypeRepository = statsByJumpTypeRepository;
|
|
||||||
_statsByYearByJumpTypeRepository = statsByYearByJumpTypeRepository;
|
|
||||||
_statsByYearRepository = statsByYearRepository;
|
|
||||||
_statsForLastMonthByDzRepository = statsForLastMonthByDzRepository;
|
|
||||||
_statsForLastMonthByJumpTypeRepository = statsForLastMonthByJumpTypeRepository;
|
|
||||||
_statsForLastYearByDzRepository = statsForLastYearByDzRepository;
|
|
||||||
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
_statsForLastYearByJumpTypeRepository = statsForLastYearByJumpTypeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,255 +23,13 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public IEnumerable<StatsForLastYearByJumpType> GetStats()
|
||||||
|
{
|
||||||
|
var allStats = _statsForLastYearByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
|
||||||
|
if (!allStats.Any())
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps();
|
var allJumps = _jumpService.GetAllJumps();
|
||||||
var results = new SimpleSummary();
|
var results = new List<StatsForLastYearByJumpType>();
|
||||||
|
|
||||||
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())
|
if (allJumps.Any())
|
||||||
{
|
{
|
||||||
@@ -297,98 +39,34 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
results = [.. allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
.GroupBy(j => j.JumpType.Name,
|
.GroupBy(j => j.JumpType.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new StatsForLastYearByJumpType
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
|
JumpType = groupby.ToString(),
|
||||||
|
Nb = jumps.Count(),
|
||||||
User = _identityService.ConnectedUser
|
User = _identityService.ConnectedUser
|
||||||
};
|
})];
|
||||||
_userStatsRepository.Add(allStats);
|
}
|
||||||
|
|
||||||
|
_statsForLastYearByJumpTypeRepository.Add(results);
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allStats;
|
return allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Private Methods
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsForLastYearByJumpTypeRepository.Delete(_identityService.ConnectedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpService _jumpService;
|
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;
|
private readonly IStatsForLastYearByJumpTypeRepository _statsForLastYearByJumpTypeRepository;
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace skydiveLogs_api.DomainBusiness
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
@@ -8,9 +9,29 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
public StatsService(IJumpService jumpService)
|
public StatsService(IJumpService jumpService,
|
||||||
|
IStatsByAircraftService statsByAircraftService,
|
||||||
|
IStatsByDzService statsByDzService,
|
||||||
|
IStatsByGearService statsByGearService,
|
||||||
|
IStatsByJumpTypeService statsByJumpTypeService,
|
||||||
|
IStatsByYearByJumpTypeService statsByYearByJumpTypeService,
|
||||||
|
IStatsByYearService statsByYearService,
|
||||||
|
IStatsForLastMonthByDzService statsForLastMonthByDzService,
|
||||||
|
IStatsForLastMonthByJumpTypeService statsForLastMonthByJumpTypeService,
|
||||||
|
IStatsForLastYearByDzService statsForLastYearByDzService,
|
||||||
|
IStatsForLastYearByJumpTypeService statsForLastYearByJumpTypeService)
|
||||||
{
|
{
|
||||||
_jumpService = jumpService;
|
_jumpService = jumpService;
|
||||||
|
_statsByAircraftService = statsByAircraftService;
|
||||||
|
_statsByDzService = statsByDzService;
|
||||||
|
_statsByGearService = statsByGearService;
|
||||||
|
_statsByJumpTypeService = statsByJumpTypeService;
|
||||||
|
_statsByYearByJumpTypeService = statsByYearByJumpTypeService;
|
||||||
|
_statsByYearService = statsByYearService;
|
||||||
|
_statsForLastMonthByDzService = statsForLastMonthByDzService;
|
||||||
|
_statsForLastMonthByJumpTypeService = statsForLastMonthByJumpTypeService;
|
||||||
|
_statsForLastYearByDzService = statsForLastYearByDzService;
|
||||||
|
_statsForLastYearByJumpTypeService = statsForLastYearByJumpTypeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
@@ -55,11 +76,122 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
// _userStatsRepository.Update(myStats);
|
// _userStatsRepository.Update(myStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByAircraft()
|
||||||
|
{
|
||||||
|
var tmp = _statsByAircraftService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.Aircraft,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByDz()
|
||||||
|
{
|
||||||
|
var tmp = _statsByDzService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.DropZone,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByGear()
|
||||||
|
{
|
||||||
|
var tmp = _statsByGearService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.Gear,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||||
|
{
|
||||||
|
var tmp = _statsByJumpTypeService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.JumpType,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYear()
|
||||||
|
{
|
||||||
|
var tmp = _statsByYearService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.Year,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
||||||
|
{
|
||||||
|
var tmp = _statsForLastMonthByDzService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.DropZone,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
||||||
|
{
|
||||||
|
var tmp = _statsForLastMonthByJumpTypeService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.JumpType,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
||||||
|
{
|
||||||
|
var tmp = _statsForLastYearByDzService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.DropZone,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
||||||
|
{
|
||||||
|
var tmp = _statsForLastYearByJumpTypeService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.JumpType,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Statistic> GetStatsByYearByJumpType()
|
||||||
|
{
|
||||||
|
var tmp = _statsByYearByJumpTypeService.GetStats();
|
||||||
|
return [.. tmp.Select(a => new Statistic
|
||||||
|
{
|
||||||
|
Label = a.Year,
|
||||||
|
Label2 = a.JumpType,
|
||||||
|
Nb = a.Nb
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly IJumpService _jumpService;
|
private readonly IJumpService _jumpService;
|
||||||
|
private readonly IStatsByAircraftService _statsByAircraftService;
|
||||||
|
private readonly IStatsByDzService _statsByDzService;
|
||||||
|
private readonly IStatsByGearService _statsByGearService;
|
||||||
|
private readonly IStatsByJumpTypeService _statsByJumpTypeService;
|
||||||
|
private readonly IStatsByYearByJumpTypeService _statsByYearByJumpTypeService;
|
||||||
|
private readonly IStatsByYearService _statsByYearService;
|
||||||
|
private readonly IStatsForLastMonthByDzService _statsForLastMonthByDzService;
|
||||||
|
private readonly IStatsForLastMonthByJumpTypeService _statsForLastMonthByJumpTypeService;
|
||||||
|
private readonly IStatsForLastYearByDzService _statsForLastYearByDzService;
|
||||||
|
private readonly IStatsForLastYearByJumpTypeService _statsForLastYearByJumpTypeService;
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsByDzRepository : IRepository<StatsByDz>
|
public interface IStatsByDzRepository : IStatsRepository<StatsByDz>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsByDz GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsByGearRepository : IRepository<StatsByGear>
|
public interface IStatsByGearRepository : IStatsRepository<StatsByGear>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsByGear GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsByJumpTypeRepository : IRepository<StatsByJumpType>
|
public interface IStatsByJumpTypeRepository : IStatsRepository<StatsByJumpType>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsByJumpType GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsByYearByJumpTypeRepository : IRepository<StatsByYearByJumpType>
|
public interface IStatsByYearByJumpTypeRepository : IStatsRepository<StatsByYearByJumpType>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsByYearByJumpType GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsByYearRepository : IRepository<StatsByYear>
|
public interface IStatsByYearRepository : IStatsRepository<StatsByYear>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsByYear GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsForLastMonthByDzRepository : IRepository<StatsForLastMonthByDz>
|
public interface IStatsForLastMonthByDzRepository : IStatsRepository<StatsForLastMonthByDz>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsForLastMonthByDz GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsForLastMonthByJumpTypeRepository : IRepository<StatsForLastMonthByJumpType>
|
public interface IStatsForLastMonthByJumpTypeRepository : IStatsRepository<StatsForLastMonthByJumpType>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsForLastMonthByJumpType GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsForLastYearByDzRepository : IRepository<StatsForLastYearByDz>
|
public interface IStatsForLastYearByDzRepository : IStatsRepository<StatsForLastYearByDz>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsForLastYearByDz GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,7 @@ using skydiveLogs_api.Domain;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
{
|
{
|
||||||
public interface IStatsForLastYearByJumpTypeRepository : IRepository<StatsForLastYearByJumpType>
|
public interface IStatsForLastYearByJumpTypeRepository : IStatsRepository<StatsForLastYearByJumpType>
|
||||||
{
|
{
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
StatsForLastYearByJumpType GetAll(User user);
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,11 +7,13 @@ namespace skydiveLogs_api.DomainService.Repositories
|
|||||||
{
|
{
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
T GetAll(User user);
|
IEnumerable<T> GetAll(User user);
|
||||||
|
|
||||||
int Add(T newEntity);
|
int Add(IEnumerable<T> newEntity);
|
||||||
|
|
||||||
bool Update(T updated);
|
bool Update(IEnumerable<T> updatedEntity, User user);
|
||||||
|
|
||||||
|
bool Delete(User user);
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsByAircraftRepository : IStatsRepository<StatsByAircraft>
|
public class StatsByAircraftRepository : IStatsByAircraftRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsByDzRepository : IStatsRepository<StatsByDz>
|
public class StatsByDzRepository : IStatsByDzRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsByDz newStats)
|
public int Add(IEnumerable<StatsByDz> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsByDz GetAll(User user)
|
public IEnumerable<StatsByDz> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsByDz stats)
|
public bool Update(IEnumerable<StatsByDz> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsByGearRepository : IStatsRepository<StatsByGear>
|
public class StatsByGearRepository : IStatsByGearRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsByGear newStats)
|
public int Add(IEnumerable<StatsByGear> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsByGear GetAll(User user)
|
public IEnumerable<StatsByGear> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsByGear stats)
|
public bool Update(IEnumerable<StatsByGear> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsByJumpTypeRepository : IStatsRepository<StatsByJumpType>
|
public class StatsByJumpTypeRepository : IStatsByJumpTypeRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsByJumpType newStats)
|
public int Add(IEnumerable<StatsByJumpType> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsByJumpType GetAll(User user)
|
public IEnumerable<StatsByJumpType> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsByJumpType stats)
|
public bool Update(IEnumerable<StatsByJumpType> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsByYearByJumpTypeRepository : IStatsRepository<StatsByYearByJumpType>
|
public class StatsByYearByJumpTypeRepository : IStatsByYearByJumpTypeRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsByYearByJumpType newStats)
|
public int Add(IEnumerable<StatsByYearByJumpType> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsByYearByJumpType GetAll(User user)
|
public IEnumerable<StatsByYearByJumpType> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsByYearByJumpType stats)
|
public bool Update(IEnumerable<StatsByYearByJumpType> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using LiteDB;
|
using LiteDB;
|
||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
using skydiveLogs_api.DomainService.Repositories;
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
@@ -5,7 +6,7 @@ using skydiveLogs_api.Infrastructure.Interfaces;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsByYearRepository : IStatsRepository<StatsByYear>
|
public class StatsByYearRepository : IStatsByYearRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -19,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsByYear newStats)
|
public int Add(IEnumerable<StatsByYear> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -36,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsByYear GetAll(User user)
|
public IEnumerable<StatsByYear> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsByYear stats)
|
public bool Update(IEnumerable<StatsByYear> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsForLastMonthByDzRepository : IStatsRepository<StatsForLastMonthByDz>
|
public class StatsForLastMonthByDzRepository : IStatsForLastMonthByDzRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsForLastMonthByDz newStats)
|
public int Add(IEnumerable<StatsForLastMonthByDz> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsForLastMonthByDz GetAll(User user)
|
public IEnumerable<StatsForLastMonthByDz> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsForLastMonthByDz stats)
|
public bool Update(IEnumerable<StatsForLastMonthByDz> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsForLastMonthByJumpTypeRepository : IStatsRepository<StatsForLastMonthByJumpType>
|
public class StatsForLastMonthByJumpTypeRepository : IStatsForLastMonthByJumpTypeRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsForLastMonthByJumpType newStats)
|
public int Add(IEnumerable<StatsForLastMonthByJumpType> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsForLastMonthByJumpType GetAll(User user)
|
public IEnumerable<StatsForLastMonthByJumpType> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsForLastMonthByJumpType stats)
|
public bool Update(IEnumerable<StatsForLastMonthByJumpType> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsForLastYearByDzRepository : IStatsRepository<StatsForLastYearByDz>
|
public class StatsForLastYearByDzRepository : IStatsForLastYearByDzRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsForLastYearByDz newStats)
|
public int Add(IEnumerable<StatsForLastYearByDz> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsForLastYearByDz GetAll(User user)
|
public IEnumerable<StatsForLastYearByDz> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsForLastYearByDz stats)
|
public bool Update(IEnumerable<StatsForLastYearByDz> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
{
|
{
|
||||||
public class StatsForLastYearByJumpTypeRepository : IStatsRepository<StatsForLastYearByJumpType>
|
public class StatsForLastYearByJumpTypeRepository : IStatsForLastYearByJumpTypeRepository
|
||||||
{
|
{
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
public int Add(StatsForLastYearByJumpType newStats)
|
public int Add(IEnumerable<StatsForLastYearByJumpType> newStats)
|
||||||
{
|
{
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
foreach (var newStat in newStats)
|
||||||
{
|
{
|
||||||
var tmp = _col.Insert(newStats);
|
var tmp = _col.Insert(newStats);
|
||||||
result = tmp.AsInt32;
|
result = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -37,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatsForLastYearByJumpType GetAll(User user)
|
public IEnumerable<StatsForLastYearByJumpType> GetAll(User user)
|
||||||
{
|
{
|
||||||
return _col.Include(x => x.User)
|
return _col.Include(x => x.User)
|
||||||
.Query()
|
.Query()
|
||||||
.Where(j => j.User.Id == user.Id)
|
.Where(j => j.User.Id == user.Id)
|
||||||
.SingleOrDefault();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(StatsForLastYearByJumpType stats)
|
public bool Update(IEnumerable<StatsForLastYearByJumpType> updatedStats, User user)
|
||||||
{
|
{
|
||||||
return _col.Update(stats);
|
Delete(user);
|
||||||
|
var tmp = Add(updatedStats);
|
||||||
|
|
||||||
|
return tmp != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(User user)
|
||||||
|
{
|
||||||
|
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||||
|
return tmp != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
Reference in New Issue
Block a user