diff --git a/src/FlightRecorder.BusinessLogic/Factory/FlightRecorderFactory.cs b/src/FlightRecorder.BusinessLogic/Factory/FlightRecorderFactory.cs index 26eebb5..238bd5c 100644 --- a/src/FlightRecorder.BusinessLogic/Factory/FlightRecorderFactory.cs +++ b/src/FlightRecorder.BusinessLogic/Factory/FlightRecorderFactory.cs @@ -23,6 +23,7 @@ public class FlightRecorderFactory private readonly Lazy> _locationStatistics = null; private readonly Lazy> _manufacturerStatistics = null; private readonly Lazy> _modelStatistics = null; + private readonly Lazy> _flightsByMonth = null; public FlightRecorderDbContext Context { get; private set; } public IAirlineManager Airlines { get { return _airlines.Value; } } public ILocationManager Locations { get { return _locations.Value; } } @@ -47,6 +48,10 @@ public class FlightRecorderFactory [ExcludeFromCodeCoverage] public IDateBasedReport ModelStatistics { get { return _modelStatistics.Value; } } + [ExcludeFromCodeCoverage] + public IDateBasedReport FlightsByMonth { get { return _flightsByMonth.Value; } } + + public FlightRecorderFactory(FlightRecorderDbContext context) { Context = context; @@ -64,6 +69,7 @@ public FlightRecorderFactory(FlightRecorderDbContext context) _locationStatistics = new Lazy>(() => new DateBasedReport(context)); _manufacturerStatistics = new Lazy>(() => new DateBasedReport(context)); _modelStatistics = new Lazy>(() => new DateBasedReport(context)); + _flightsByMonth = new Lazy>(() => new DateBasedReport(context)); } } } diff --git a/src/FlightRecorder.BusinessLogic/FlightRecorder.BusinessLogic.csproj b/src/FlightRecorder.BusinessLogic/FlightRecorder.BusinessLogic.csproj index e23b4af..319bdd3 100644 --- a/src/FlightRecorder.BusinessLogic/FlightRecorder.BusinessLogic.csproj +++ b/src/FlightRecorder.BusinessLogic/FlightRecorder.BusinessLogic.csproj @@ -3,7 +3,7 @@ net7.0 FlightRecorder.BusinessLogic - 1.1.3.0 + 1.1.4.0 Dave Walker Copyright (c) Dave Walker 2020, 2021, 2022, 2023 Dave Walker @@ -16,7 +16,7 @@ https://github.com/davewalker5/FlightRecorderDb MIT false - 1.1.3.0 + 1.1.4.0 @@ -28,6 +28,7 @@ + @@ -36,6 +37,7 @@ Never + Never diff --git a/src/FlightRecorder.BusinessLogic/Sql/FlightsByMonth.sql b/src/FlightRecorder.BusinessLogic/Sql/FlightsByMonth.sql new file mode 100644 index 0000000..058108b --- /dev/null +++ b/src/FlightRecorder.BusinessLogic/Sql/FlightsByMonth.sql @@ -0,0 +1,10 @@ +SELECT STRFTIME('%Y', s.Date ) AS "Year", + STRFTIME('%m', s.Date ) AS "Month", + COUNT( DISTINCT s.Id ) AS "Sightings", + COUNT( DISTINCT f.Id ) AS "Flights" +FROM AIRLINE a +INNER JOIN FLIGHT f ON f.Airline_Id = a.Id +INNER JOIN SIGHTING s ON s.Flight_Id = f.Id +WHERE s.Date BETWEEN '$from' AND '$to' +GROUP BY STRFTIME('%Y', s.Date ), STRFTIME('%m', s.Date ) +ORDER BY s.Date ASC; diff --git a/src/FlightRecorder.Data/FlightRecorder.Data.csproj b/src/FlightRecorder.Data/FlightRecorder.Data.csproj index 06f3c5e..98a4cf9 100644 --- a/src/FlightRecorder.Data/FlightRecorder.Data.csproj +++ b/src/FlightRecorder.Data/FlightRecorder.Data.csproj @@ -3,7 +3,7 @@ net7.0 FlightRecorder.Data - 1.1.3.0 + 1.1.4.0 Dave Walker Copyright (c) Dave Walker 2020, 2021, 2022, 2023 Dave Walker @@ -16,7 +16,7 @@ https://github.com/davewalker5/FlightRecorderDb MIT false - 1.1.3.0 + 1.1.4.0 diff --git a/src/FlightRecorder.Data/FlightRecorderDbContext.cs b/src/FlightRecorder.Data/FlightRecorderDbContext.cs index ccd5f08..83df0c6 100644 --- a/src/FlightRecorder.Data/FlightRecorderDbContext.cs +++ b/src/FlightRecorder.Data/FlightRecorderDbContext.cs @@ -22,6 +22,7 @@ public partial class FlightRecorderDbContext : DbContext public virtual DbSet LocationStatistics { get; set; } public virtual DbSet ManufacturerStatistics { get; set; } public virtual DbSet ModelStatistics { get; set; } + public virtual DbSet FlightsByMonth { get; set; } public FlightRecorderDbContext(DbContextOptions options) : base(options) { @@ -37,6 +38,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().HasNoKey(); modelBuilder.Entity().HasNoKey(); modelBuilder.Entity().HasNoKey(); + modelBuilder.Entity().HasNoKey(); modelBuilder.Entity(entity => { diff --git a/src/FlightRecorder.DataExchange/FlightRecorder.DataExchange.csproj b/src/FlightRecorder.DataExchange/FlightRecorder.DataExchange.csproj index cc381b3..562703e 100644 --- a/src/FlightRecorder.DataExchange/FlightRecorder.DataExchange.csproj +++ b/src/FlightRecorder.DataExchange/FlightRecorder.DataExchange.csproj @@ -3,7 +3,7 @@ net7.0 FlightRecorder.DataExchange - 1.1.3.0 + 1.1.4.0 Dave Walker Copyright (c) Dave Walker 2020, 2021, 2022, 2023 Dave Walker @@ -16,7 +16,7 @@ https://github.com/davewalker5/FlightRecorderDb MIT false - 1.1.3.0 + 1.1.4.0 diff --git a/src/FlightRecorder.Entities/FlightRecorder.Entities.csproj b/src/FlightRecorder.Entities/FlightRecorder.Entities.csproj index 5003b1f..27aa00e 100644 --- a/src/FlightRecorder.Entities/FlightRecorder.Entities.csproj +++ b/src/FlightRecorder.Entities/FlightRecorder.Entities.csproj @@ -3,7 +3,7 @@ net7.0 FlightRecorder.Entities - 1.1.3.0 + 1.1.4.0 Dave Walker Copyright (c) Dave Walker 2020, 2021, 2022, 2023 Dave Walker @@ -16,7 +16,7 @@ https://github.com/davewalker5/FlightRecorderDb MIT false - 1.1.3.0 + 1.1.4.0 diff --git a/src/FlightRecorder.Entities/Reporting/FlightsByMonth.cs b/src/FlightRecorder.Entities/Reporting/FlightsByMonth.cs new file mode 100644 index 0000000..646def7 --- /dev/null +++ b/src/FlightRecorder.Entities/Reporting/FlightsByMonth.cs @@ -0,0 +1,15 @@ +using Microsoft.EntityFrameworkCore; +using System.Diagnostics.CodeAnalysis; + +namespace FlightRecorder.Entities.Reporting +{ + [Keyless] + [ExcludeFromCodeCoverage] + public class FlightsByMonth + { + public int Year { get; set; } + public int Month { get; set; } + public int? Sightings { get; set; } + public int? Flights { get; set; } + } +} diff --git a/src/FlightRecorder.Manager/FlightRecorder.Manager.csproj b/src/FlightRecorder.Manager/FlightRecorder.Manager.csproj index 835fa08..449eaa8 100644 --- a/src/FlightRecorder.Manager/FlightRecorder.Manager.csproj +++ b/src/FlightRecorder.Manager/FlightRecorder.Manager.csproj @@ -3,9 +3,9 @@ Exe net7.0 - 1.1.3.0 - 1.1.3.0 - 1.1.3.0 + 1.1.4.0 + 1.1.4.0 + 1.1.4.0 Release;Debug false diff --git a/src/FlightRecorder.Tests/FlightRecorder.Tests.csproj b/src/FlightRecorder.Tests/FlightRecorder.Tests.csproj index 5437acd..74a0d68 100644 --- a/src/FlightRecorder.Tests/FlightRecorder.Tests.csproj +++ b/src/FlightRecorder.Tests/FlightRecorder.Tests.csproj @@ -4,7 +4,7 @@ net7.0 false - 1.1.3.0 + 1.1.4.0