Sort entries both on the backend and frontend
This commit is contained in:
@@ -34,10 +34,12 @@ export class EntriesOverviewService {
|
|||||||
return combineLatest([this.cachedCars$!, entries$])
|
return combineLatest([this.cachedCars$!, entries$])
|
||||||
.pipe(
|
.pipe(
|
||||||
map(([cars, entries]) => {
|
map(([cars, entries]) => {
|
||||||
return entries.map((entry): Consumption => ({
|
return entries
|
||||||
...entry,
|
.sort((a, b) => b.dateTime.localeCompare(a.dateTime))
|
||||||
car: cars.find(car => car.id === entry.carId)!
|
.map((entry): Consumption => ({
|
||||||
}));
|
...entry,
|
||||||
|
car: cars.find(car => car.id === entry.carId)!
|
||||||
|
}));
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public static class GetConsumptions
|
|||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
List<ResponseDto> consumptions = await dbContext.Consumptions
|
List<ResponseDto> consumptions = await dbContext.Consumptions
|
||||||
|
.OrderByDescending(x => x.DateTime)
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
new ResponseDto(x.Id.Value, x.DateTime, x.Distance, x.Amount, x.IgnoreInCalculation, x.CarId.Value))
|
new ResponseDto(x.Id.Value, x.DateTime, x.Distance, x.Amount, x.IgnoreInCalculation, x.CarId.Value))
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|||||||
Reference in New Issue
Block a user