Ensure correct sorting and thus also correct liter per 100km calculation
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -73,7 +73,7 @@ export class EntriesComponent implements OnInit {
|
||||
const entries = this.consumptionClient.getAll()
|
||||
.pipe(
|
||||
takeUntilDestroyed(),
|
||||
map(response => response.consumptions),
|
||||
map(response => response.consumptions.sort((a, b) => b.dateTime.localeCompare(a.dateTime))),
|
||||
catchError((error) => this.handleGetEntriesError(error))
|
||||
);
|
||||
|
||||
|
||||
@@ -52,10 +52,9 @@ public static class GetConsumptions
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
Dictionary<CarId, List<Consumption>> consumptionsByCar = await dbContext.Consumptions
|
||||
.OrderByDescending(x => x.DateTime)
|
||||
.Include(x => x.Car)
|
||||
.GroupBy(x => x.CarId)
|
||||
.ToDictionaryAsync(x => x.Key, x => x.ToList(), cancellationToken);
|
||||
.ToDictionaryAsync(x => x.Key, x => x.OrderByDescending(x => x.DateTime).ToList(), cancellationToken);
|
||||
|
||||
List<ResponseDto> responses = [];
|
||||
|
||||
@@ -85,7 +84,10 @@ public static class GetConsumptions
|
||||
}
|
||||
}
|
||||
|
||||
ApiResponse apiResponse = new() { Consumptions = responses };
|
||||
ApiResponse apiResponse = new()
|
||||
{
|
||||
Consumptions = responses
|
||||
};
|
||||
return TypedResults.Ok(apiResponse);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user