Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:latest
COPY flightrecorder.api-1.21.0.0 /opt/flightrecorder.api
COPY flightrecorder.api-1.24.0.0 /opt/flightrecorder.api
WORKDIR /opt/flightrecorder.api/bin
ENTRYPOINT [ "./FlightRecorder.Api" ]
2 changes: 1 addition & 1 deletion docker/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:latest AS runtime
COPY flightrecorder.mvc-1.21.0.0 /opt/flightrecorder.mvc
COPY flightrecorder.mvc-1.24.0.0 /opt/flightrecorder.mvc
WORKDIR /opt/flightrecorder.mvc/bin
ENTRYPOINT [ "./FlightRecorder.Mvc" ]
26 changes: 17 additions & 9 deletions src/FlightRecorder.Api/Controllers/FlightsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@ public async Task<ActionResult<List<Flight>>> GetFlightsByRouteAsync(string emba
{
LogMessage(Severity.Debug, $"Retrieving list of flights by route {embarkation}-{destination} (page {pageNumber}, page size {pageSize})");

// Retrieve the matching list of flights
string decodedEmbarkation = HttpUtility.UrlDecode(embarkation).ToUpper();
string decodedDestination = HttpUtility.UrlDecode(destination).ToUpper();
List<Flight> flights = await Factory.Flights
.ListAsync(f => (f.Embarkation == decodedEmbarkation) &&
(f.Destination == decodedDestination), pageNumber, pageSize)
.ToListAsync();

LogMessage(Severity.Debug, $"Retrieved {flights.Count} flights(s)");
LogMessage(Severity.Debug, $"Retrieved {flights.Count} flight(s)");

if (!flights.Any())
{
return NoContent();
}

// Assign airport details
// Assign airport and sighting details
await Factory.Airports.LoadAirportDetails(flights);
await Factory.Sightings.LoadSightingDetails(flights);

return flights;
}
Expand All @@ -54,15 +56,16 @@ public async Task<ActionResult<List<Flight>>> GetFlightsByAirlineAsync(int airli
.ListAsync(f => f.AirlineId == airlineId, pageNumber, pageSize)
.ToListAsync();

LogMessage(Severity.Debug, $"Retrieved {flights.Count} flights(s)");
LogMessage(Severity.Debug, $"Retrieved {flights.Count} flight(s)");

if (!flights.Any())
{
return NoContent();
}

// Assign airport details
// Assign airport and sighting details
await Factory.Airports.LoadAirportDetails(flights);
await Factory.Sightings.LoadSightingDetails(flights);

return flights;
}
Expand All @@ -78,15 +81,16 @@ public async Task<ActionResult<List<Flight>>> GetFlightsByNumberAsync(string num
.ListAsync(f => f.Number == decodedNumber, pageNumber, pageSize)
.ToListAsync();

LogMessage(Severity.Debug, $"Retrieved {flights.Count} flights(s)");
LogMessage(Severity.Debug, $"Retrieved {flights.Count} flight(s)");

if (!flights.Any())
{
return NoContent();
}

// Assign airport details
// Assign airport and sighting details
await Factory.Airports.LoadAirportDetails(flights);
await Factory.Sightings.LoadSightingDetails(flights);

return flights;
}
Expand All @@ -105,8 +109,9 @@ public async Task<ActionResult<Flight>> GetFlightByIdAsync(int id)
return NotFound();
}

// Assign airport details
// Assign airport and sighting details
await Factory.Airports.LoadAirportDetails([flight]);
await Factory.Sightings.LoadSightingDetails([flight]);

return flight;
}
Expand All @@ -123,8 +128,10 @@ public async Task<ActionResult<Flight>> AddFlightAsync([FromBody] Flight templat
template.AirlineId);
LogMessage(Severity.Debug, $"Added flight: {flight}");

// Assign airport details
// Assign airport and sighting details
await Factory.Airports.LoadAirportDetails([flight]);
await Factory.Sightings.LoadSightingDetails([flight]);

return flight;
}

Expand All @@ -141,8 +148,9 @@ public async Task<ActionResult<Flight>> UpdateFlightAsync([FromBody] Flight temp
template.Destination,
template.AirlineId);

// Assign airport details
// Assign airport and sighting details
await Factory.Airports.LoadAirportDetails([flight]);
await Factory.Sightings.LoadSightingDetails([flight]);

LogMessage(Severity.Debug, $"Flight updated: {flight}");

Expand Down
6 changes: 3 additions & 3 deletions src/FlightRecorder.Api/FlightRecorder.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<FileVersion>1.23.0.0</FileVersion>
<ProductVersion>1.23.0</ProductVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<FileVersion>1.24.0.0</FileVersion>
<ProductVersion>1.24.0</ProductVersion>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<NoWarn>NU1900</NoWarn>
Expand Down
26 changes: 26 additions & 0 deletions src/FlightRecorder.BusinessLogic/Database/SightingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,5 +356,31 @@ public async Task<IAsyncEnumerable<Sighting>> ListByLocationAsync(string locatio

return sightings;
}

/// <summary>
/// Assign the last seen date on a collection of flights
/// </summary>
/// <param name="flights"></param>
/// <returns></returns>
public async Task LoadSightingDetails(IEnumerable<Flight> flights)
{
// Get a list of flight IDs
var flightIds = flights.Select(x => x.Id).Distinct();

// Load matching sighting details
var sightings = await ListAsync(x => flightIds.Contains(x.FlightId), 1, int.MaxValue).ToListAsync();

// Map them into the flights
foreach (var flight in flights)
{
// Find the most recent sighting for this flight
var sighting = sightings.Where(s => s.FlightId == flight.Id)
.OrderByDescending(s => s.Date)
.FirstOrDefault();

// Set the last seen date on the flight from the sighting
flight.LastSeen = sighting.Date;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<PackageId>FlightRecorder.BusinessLogic</PackageId>
<PackageVersion>1.23.0.0</PackageVersion>
<PackageVersion>1.24.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023, 2024, 2025</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -12,10 +12,10 @@
<Title>Flight Recorder Business Logic</Title>
<Description>FlightRecorder business logic</Description>
<PackOnBuild>true</PackOnBuild>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorder</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<NoWarn>NU1900</NoWarn>
</PropertyGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/FlightRecorder.Client/ApiClient/FlightClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public async Task<List<Flight>> GetFlightsByNumberAsync(string number)
if (!string.IsNullOrEmpty(json))
{
flights = Deserialize<List<Flight>>(json)
?.OrderBy(m => m.Airline.Name)
?.OrderByDescending(m => m.LastSeen)
.ThenBy(m => m.Airline.Name)
.ThenBy(m => m.Embarkation)
.ThenBy(m => m.Destination)
.ToList();
Expand Down
6 changes: 3 additions & 3 deletions src/FlightRecorder.Client/FlightRecorder.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<PackageId>FlightRecorder.Client</PackageId>
<PackageVersion>1.23.0.0</PackageVersion>
<PackageVersion>1.24.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023, 2024, 2025</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -12,10 +12,10 @@
<Title>Flight Recorder Client API</Title>
<Description>FlightRecorder Client API</Description>
<PackOnBuild>true</PackOnBuild>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorder</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<NoWarn>NU1900</NoWarn>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 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>net9.0</TargetFramework>
<PackageId>FlightRecorder.Data</PackageId>
<PackageVersion>1.23.0.0</PackageVersion>
<PackageVersion>1.24.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023, 2024, 2025</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -12,10 +12,10 @@
<Title>Flight Recorder EF Core Database Layer</Title>
<Description>FlightRecorder EF Core Database Layer</Description>
<PackOnBuild>true</PackOnBuild>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorder</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<NoWarn>NU1900</NoWarn>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<PackageId>FlightRecorder.DataExchange</PackageId>
<PackageVersion>1.23.0.0</PackageVersion>
<PackageVersion>1.24.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023, 2024, 2025</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -12,10 +12,10 @@
<Title>Flight Recorder Data Exchange Tools</Title>
<Description>FlightRecorder Data Exchange Tools</Description>
<PackOnBuild>true</PackOnBuild>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorder</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<NoWarn>NU1900</NoWarn>
</PropertyGroup>

Expand Down
6 changes: 5 additions & 1 deletion src/FlightRecorder.Entities/Db/Flight.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -36,6 +37,9 @@ public partial class Flight : FlightRecorderEntityBase
[NotMapped]
public Airport DestinationAirport { get; set; }

[NotMapped]
public DateTime? LastSeen { get; set; }

public virtual Airline Airline { get; set; }

public string Route { get { return $"{Embarkation} - {Destination}"; } }
Expand Down
8 changes: 4 additions & 4 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>net9.0</TargetFramework>
<PackageId>FlightRecorder.Entities</PackageId>
<PackageVersion>1.23.0.0</PackageVersion>
<PackageVersion>1.24.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023, 2024, 2025</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -12,10 +12,10 @@
<Title>Flight Recorder Domain Models</Title>
<Description>FlightRecorder Domain Models</Description>
<PackOnBuild>true</PackOnBuild>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorder</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<NoWarn>NU1900</NoWarn>
</PropertyGroup>

Expand All @@ -26,6 +26,6 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Interfaces\IFlightRecorderDbContext.cs" />
<Compile Remove="Interfaces\IFlightRecorderContext.cs" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/FlightRecorder.Entities/Interfaces/ISightingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public interface ISightingManager
Task<IAsyncEnumerable<Sighting>> ListByLocationAsync(string locationName, int pageNumber, int pageSize);
Task<Sighting> UpdateAsync(long id, long altitude, DateTime date, long locationId, long flightId, long aircraftId, bool isMyFlight);
Task DeleteAsync(long id);
Task LoadSightingDetails(IEnumerable<Flight> flights);
}
}
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>net9.0</TargetFramework>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<FileVersion>1.23.0.0</FileVersion>
<ProductVersion>1.23.0.0</ProductVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<FileVersion>1.24.0.0</FileVersion>
<ProductVersion>1.24.0.0</ProductVersion>
<Configurations>Release;Debug</Configurations>
<NoWarn>NU1900</NoWarn>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/FlightRecorder.Mvc/FlightRecorder.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<FileVersion>1.23.0.0</FileVersion>
<ProductVersion>1.23.0</ProductVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<FileVersion>1.24.0.0</FileVersion>
<ProductVersion>1.24.0</ProductVersion>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<NoWarn>NU1900</NoWarn>
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 @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<ReleaseVersion>1.23.0.0</ReleaseVersion>
<ReleaseVersion>1.24.0.0</ReleaseVersion>
<NoWarn>NU1900</NoWarn>
</PropertyGroup>

Expand Down