Update for the tunnel graph to have the stats my month and type of flights

This commit is contained in:
Sébastien ANDRE
2023-08-22 13:04:29 +02:00
parent e21ab458b1
commit 7abfa2b2b7
6 changed files with 26 additions and 10 deletions

View File

@@ -6,6 +6,8 @@
public string Label { get; set; }
public string Label2 { get; set; }
public int Nb { get; set; }
#endregion Public Properties

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
namespace skydiveLogs_api.Domain
{

View File

@@ -56,11 +56,12 @@ namespace skydiveLogs_api.DomainBusiness
if (allTunnelFlights.Any())
{
results = allTunnelFlights.GroupBy(j => j.FlightDate.ToString("yy-MM"),
results = allTunnelFlights.GroupBy(j => new { FlightDate = j.FlightDate.ToString("yy-MM"), j.JumpType },
j => j,
(groupby, tunnelFlights) => new Statistic
{
Label = groupby.ToString(),
Label = groupby.FlightDate,
Label2 = groupby.JumpType.Name,
Nb = tunnelFlights.Sum(t => t.NbMinutes)
})
.ToList();

View File

@@ -53,10 +53,10 @@ namespace skydiveLogs_api.Controllers
// GET: api/TunnelFlight/month/20230101/20230701
[HttpGet("month/{beginDate}/{endDate}")]
[EnableCors]
public IEnumerable<StatisticResp> GetGroupByMonth(string beginDate, string endDate)
public IEnumerable<StatisticForChartResp> GetGroupByMonth(string beginDate, string endDate)
{
var result = _tunnelFlightService.GetTunnelFlightGroupByMonth(beginDate, endDate);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
return _mapper.Map<IEnumerable<StatisticForChartResp>>(result);
}
// POST: api/Tunnel

View File

@@ -0,0 +1,11 @@
namespace skydiveLogs_api.DataContract
{
public class StatisticForChartResp
{
public string Label { get; set; }
public string Label2 { get; set; }
public int Nb { get; set; }
}
}

View File

@@ -19,23 +19,26 @@ namespace skydiveLogs_api.Mapper
CreateMap<DataContract.ImageReq, UserImage>();
CreateMap<DataContract.TunnelFlightReq, TunnelFlight>();
CreateMap<Gear, DataContract.GearResp>();
CreateMap<Jump, DataContract.JumpResp>().ForMember(dest => dest.AircraftId, opt => opt.MapFrom(s => s.Aircraft.Id))
.ForMember(dest => dest.DropZoneId, opt => opt.MapFrom(s => s.DropZone.Id))
.ForMember(dest => dest.GearId, opt => opt.MapFrom(s => s.Gear.Id))
.ForMember(dest => dest.JumpTypeId, opt => opt.MapFrom(s => s.JumpType.Id));
CreateMap<TunnelFlight, DataContract.TunnelFlightResp>();
CreateMap<Gear, DataContract.GearResp>();
CreateMap<JumpType, DataContract.JumpTypeResp>();
CreateMap<Aircraft, DataContract.AircraftResp>();
CreateMap<Aircraft, DataContract.AircraftSimpleResp>();
CreateMap<DropZone, DataContract.DropZoneResp>();
CreateMap<DropZone, DataContract.DropZoneSimpleResp>();
CreateMap<Tunnel, DataContract.TunnelResp>();
CreateMap<Statistic, DataContract.StatisticResp>();
CreateMap<Statistic, DataContract.StatisticForChartResp>();
CreateMap<SimpleSummary, DataContract.SimpleSummaryResp>();
CreateMap<User, DataContract.UserResp>();
CreateMap<UserImage, DataContract.ImageResp>();
CreateMap<Tunnel, DataContract.TunnelResp>();
CreateMap<TunnelFlight, DataContract.TunnelFlightResp>();
CreateMap<SimpleSummary, DataContract.SimpleSummaryResp>();
}
#endregion Public Constructors