UX Improvements
This commit is contained in:
@@ -85,7 +85,17 @@ export class FuelLogsService {
|
||||
if (cached) return cached;
|
||||
|
||||
const rows = await this.repository.findByVehicleIdEnhanced(vehicleId);
|
||||
const response = rows.map(r => this.toEnhancedResponse(r, undefined, unitSystem));
|
||||
const response = rows.map(r => {
|
||||
const efficiency = EfficiencyCalculationService.calculateEfficiency(
|
||||
{
|
||||
tripDistance: r.trip_distance ?? undefined,
|
||||
fuelUnits: r.fuel_units ?? undefined
|
||||
},
|
||||
null, // No previous odometer needed for trip distance calculation
|
||||
unitSystem
|
||||
);
|
||||
return this.toEnhancedResponse(r, efficiency?.value ?? undefined, unitSystem);
|
||||
});
|
||||
await cacheService.set(cacheKey, response, this.cacheTTL);
|
||||
return response;
|
||||
}
|
||||
@@ -96,7 +106,17 @@ export class FuelLogsService {
|
||||
const cached = await cacheService.get<EnhancedFuelLogResponse[]>(cacheKey);
|
||||
if (cached) return cached;
|
||||
const rows = await this.repository.findByUserIdEnhanced(userId);
|
||||
const response = rows.map(r => this.toEnhancedResponse(r, undefined, unitSystem));
|
||||
const response = rows.map(r => {
|
||||
const efficiency = EfficiencyCalculationService.calculateEfficiency(
|
||||
{
|
||||
tripDistance: r.trip_distance ?? undefined,
|
||||
fuelUnits: r.fuel_units ?? undefined
|
||||
},
|
||||
null, // No previous odometer needed for trip distance calculation
|
||||
unitSystem
|
||||
);
|
||||
return this.toEnhancedResponse(r, efficiency?.value ?? undefined, unitSystem);
|
||||
});
|
||||
await cacheService.set(cacheKey, response, this.cacheTTL);
|
||||
return response;
|
||||
}
|
||||
@@ -106,7 +126,17 @@ export class FuelLogsService {
|
||||
if (!row) throw new Error('Fuel log not found');
|
||||
if (row.user_id !== userId) throw new Error('Unauthorized');
|
||||
const { unitSystem } = await UserSettingsService.getUserSettings(userId);
|
||||
return this.toEnhancedResponse(row, undefined, unitSystem);
|
||||
|
||||
const efficiency = EfficiencyCalculationService.calculateEfficiency(
|
||||
{
|
||||
tripDistance: row.trip_distance ?? undefined,
|
||||
fuelUnits: row.fuel_units ?? undefined
|
||||
},
|
||||
null, // No previous odometer needed for trip distance calculation
|
||||
unitSystem
|
||||
);
|
||||
|
||||
return this.toEnhancedResponse(row, efficiency?.value ?? undefined, unitSystem);
|
||||
}
|
||||
|
||||
async updateFuelLog(id: string, data: EnhancedUpdateFuelLogRequest, userId: string): Promise<EnhancedFuelLogResponse> {
|
||||
|
||||
Reference in New Issue
Block a user