Skip to content

Commit

Permalink
Merge pull request #18 from davewalker5/FR-15-Flights-By-Month-Report
Browse files Browse the repository at this point in the history
Added the flights by month report
  • Loading branch information
davewalker5 authored Oct 23, 2023
2 parents e0d6dda + 6619a77 commit 8e6f3e2
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class FlightRecorderFactory
private readonly Lazy<IDateBasedReport<LocationStatistics>> _locationStatistics = null;
private readonly Lazy<IDateBasedReport<ManufacturerStatistics>> _manufacturerStatistics = null;
private readonly Lazy<IDateBasedReport<ModelStatistics>> _modelStatistics = null;
private readonly Lazy<IDateBasedReport<FlightsByMonth>> _flightsByMonth = null;
public FlightRecorderDbContext Context { get; private set; }
public IAirlineManager Airlines { get { return _airlines.Value; } }
public ILocationManager Locations { get { return _locations.Value; } }
Expand All @@ -47,6 +48,10 @@ public class FlightRecorderFactory
[ExcludeFromCodeCoverage]
public IDateBasedReport<ModelStatistics> ModelStatistics { get { return _modelStatistics.Value; } }

[ExcludeFromCodeCoverage]
public IDateBasedReport<FlightsByMonth> FlightsByMonth { get { return _flightsByMonth.Value; } }


public FlightRecorderFactory(FlightRecorderDbContext context)
{
Context = context;
Expand All @@ -64,6 +69,7 @@ public FlightRecorderFactory(FlightRecorderDbContext context)
_locationStatistics = new Lazy<IDateBasedReport<LocationStatistics>>(() => new DateBasedReport<LocationStatistics>(context));
_manufacturerStatistics = new Lazy<IDateBasedReport<ManufacturerStatistics>>(() => new DateBasedReport<ManufacturerStatistics>(context));
_modelStatistics = new Lazy<IDateBasedReport<ModelStatistics>>(() => new DateBasedReport<ModelStatistics>(context));
_flightsByMonth = new Lazy<IDateBasedReport<FlightsByMonth>>(() => new DateBasedReport<FlightsByMonth>(context));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.BusinessLogic</PackageId>
<PackageVersion>1.1.3.0</PackageVersion>
<PackageVersion>1.1.4.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.1.3.0</ReleaseVersion>
<ReleaseVersion>1.1.4.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -28,6 +28,7 @@
</ItemGroup>
<ItemGroup>
<None Remove="Sql\AirlineStatistics.sql" />
<None Remove="Sql\FlightsByMonth.sql" />
<None Remove="Sql\LocationStatistics.sql" />
<None Remove="Sql\ManufacturerStatistics.sql" />
<None Remove="Sql\ModelStatistics.sql" />
Expand All @@ -36,6 +37,7 @@
<EmbeddedResource Include="Sql\AirlineStatistics.sql">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sql\FlightsByMonth.sql" />
<EmbeddedResource Include="Sql\LocationStatistics.sql">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
Expand Down
10 changes: 10 additions & 0 deletions src/FlightRecorder.BusinessLogic/Sql/FlightsByMonth.sql
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions src/FlightRecorder.Data/FlightRecorder.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.Data</PackageId>
<PackageVersion>1.1.3.0</PackageVersion>
<PackageVersion>1.1.4.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.1.3.0</ReleaseVersion>
<ReleaseVersion>1.1.4.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/FlightRecorder.Data/FlightRecorderDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public partial class FlightRecorderDbContext : DbContext
public virtual DbSet<LocationStatistics> LocationStatistics { get; set; }
public virtual DbSet<ManufacturerStatistics> ManufacturerStatistics { get; set; }
public virtual DbSet<ModelStatistics> ModelStatistics { get; set; }
public virtual DbSet<FlightsByMonth> FlightsByMonth { get; set; }

public FlightRecorderDbContext(DbContextOptions<FlightRecorderDbContext> options) : base(options)
{
Expand All @@ -37,6 +38,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<LocationStatistics>().HasNoKey();
modelBuilder.Entity<ManufacturerStatistics>().HasNoKey();
modelBuilder.Entity<ModelStatistics>().HasNoKey();
modelBuilder.Entity<FlightsByMonth>().HasNoKey();

modelBuilder.Entity<Aircraft>(entity =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.DataExchange</PackageId>
<PackageVersion>1.1.3.0</PackageVersion>
<PackageVersion>1.1.4.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.1.3.0</ReleaseVersion>
<ReleaseVersion>1.1.4.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FlightRecorder.Entities/FlightRecorder.Entities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.Entities</PackageId>
<PackageVersion>1.1.3.0</PackageVersion>
<PackageVersion>1.1.4.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.1.3.0</ReleaseVersion>
<ReleaseVersion>1.1.4.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/FlightRecorder.Entities/Reporting/FlightsByMonth.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
6 changes: 3 additions & 3 deletions src/FlightRecorder.Manager/FlightRecorder.Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.1.3.0</ReleaseVersion>
<FileVersion>1.1.3.0</FileVersion>
<ProductVersion>1.1.3.0</ProductVersion>
<ReleaseVersion>1.1.4.0</ReleaseVersion>
<FileVersion>1.1.4.0</FileVersion>
<ProductVersion>1.1.4.0</ProductVersion>
<Configurations>Release;Debug</Configurations>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/FlightRecorder.Tests/FlightRecorder.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>1.1.3.0</ReleaseVersion>
<ReleaseVersion>1.1.4.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 8e6f3e2

Please sign in to comment.