Notification updates
This commit is contained in:
@@ -247,7 +247,7 @@ export class FuelLogsRepository {
|
||||
data.notes ?? null
|
||||
];
|
||||
const res = await this.pool.query(query, values);
|
||||
return res.rows[0];
|
||||
return res.rows[0] ? this.mapRow(res.rows[0]) : null;
|
||||
}
|
||||
|
||||
async findByVehicleIdEnhanced(vehicleId: string): Promise<any[]> {
|
||||
@@ -255,7 +255,7 @@ export class FuelLogsRepository {
|
||||
`SELECT * FROM fuel_logs WHERE vehicle_id = $1 ORDER BY date_time DESC NULLS LAST, date DESC NULLS LAST, created_at DESC`,
|
||||
[vehicleId]
|
||||
);
|
||||
return res.rows;
|
||||
return res.rows.map(row => this.mapRow(row));
|
||||
}
|
||||
|
||||
async findByUserIdEnhanced(userId: string): Promise<any[]> {
|
||||
@@ -263,12 +263,12 @@ export class FuelLogsRepository {
|
||||
`SELECT * FROM fuel_logs WHERE user_id = $1 ORDER BY date_time DESC NULLS LAST, date DESC NULLS LAST, created_at DESC`,
|
||||
[userId]
|
||||
);
|
||||
return res.rows;
|
||||
return res.rows.map(row => this.mapRow(row));
|
||||
}
|
||||
|
||||
async findByIdEnhanced(id: string): Promise<any | null> {
|
||||
const res = await this.pool.query(`SELECT * FROM fuel_logs WHERE id = $1`, [id]);
|
||||
return res.rows[0] || null;
|
||||
return res.rows[0] ? this.mapRow(res.rows[0]) : null;
|
||||
}
|
||||
|
||||
async getPreviousLogByOdometer(vehicleId: string, odometerReading: number): Promise<any | null> {
|
||||
@@ -276,7 +276,7 @@ export class FuelLogsRepository {
|
||||
`SELECT * FROM fuel_logs WHERE vehicle_id = $1 AND odometer IS NOT NULL AND odometer < $2 ORDER BY odometer DESC LIMIT 1`,
|
||||
[vehicleId, odometerReading]
|
||||
);
|
||||
return res.rows[0] || null;
|
||||
return res.rows[0] ? this.mapRow(res.rows[0]) : null;
|
||||
}
|
||||
|
||||
async getLatestLogForVehicle(vehicleId: string): Promise<any | null> {
|
||||
@@ -284,7 +284,7 @@ export class FuelLogsRepository {
|
||||
`SELECT * FROM fuel_logs WHERE vehicle_id = $1 ORDER BY date_time DESC NULLS LAST, date DESC NULLS LAST, created_at DESC LIMIT 1`,
|
||||
[vehicleId]
|
||||
);
|
||||
return res.rows[0] || null;
|
||||
return res.rows[0] ? this.mapRow(res.rows[0]) : null;
|
||||
}
|
||||
|
||||
async updateEnhanced(id: string, data: {
|
||||
@@ -370,6 +370,6 @@ export class FuelLogsRepository {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result.rows[0];
|
||||
return this.mapRow(result.rows[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user