update
This commit is contained in:
@@ -406,6 +406,43 @@ class VehicleService {
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// MAINTENANCE WINDOWS (for booking calendar overlay)
|
||||
// =========================================================================
|
||||
|
||||
async getMaintenanceWindows(
|
||||
from: Date,
|
||||
to: Date
|
||||
): Promise<
|
||||
{
|
||||
id: string;
|
||||
bezeichnung: string;
|
||||
kurzname: string | null;
|
||||
status: string;
|
||||
status_bemerkung: string | null;
|
||||
ausser_dienst_von: string;
|
||||
ausser_dienst_bis: string;
|
||||
}[]
|
||||
> {
|
||||
try {
|
||||
const result = await pool.query(
|
||||
`SELECT id, bezeichnung, kurzname, status, status_bemerkung,
|
||||
ausser_dienst_von, ausser_dienst_bis
|
||||
FROM fahrzeuge
|
||||
WHERE deleted_at IS NULL
|
||||
AND status IN ('ausser_dienst_wartung', 'ausser_dienst_schaden')
|
||||
AND ausser_dienst_von IS NOT NULL
|
||||
AND ausser_dienst_bis IS NOT NULL
|
||||
AND (ausser_dienst_von, ausser_dienst_bis) OVERLAPS ($1, $2)`,
|
||||
[from, to]
|
||||
);
|
||||
return result.rows;
|
||||
} catch (error) {
|
||||
logger.error('VehicleService.getMaintenanceWindows failed', { error });
|
||||
throw new Error('Failed to fetch maintenance windows');
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// DASHBOARD KPI
|
||||
// =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user