fix: 本周动态也基于权限过滤后的车辆计算
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -509,7 +509,8 @@ async function getWeeklyStats(): Promise<WeeklyStats> {
|
|||||||
|
|
||||||
// GET /api/vehicles/summary
|
// GET /api/vehicles/summary
|
||||||
app.get('/summary', async (c) => {
|
app.get('/summary', async (c) => {
|
||||||
const [vehicles, weekly] = await Promise.all([getVehiclesForUser(c), getWeeklyStats()]);
|
const [vehicles, weeklyIds] = await Promise.all([getVehiclesForUser(c), getWeeklyTruckIds()]);
|
||||||
|
const vehicleIds = new Set(vehicles.map(v => String(v.id)));
|
||||||
const summary: SummaryData = {
|
const summary: SummaryData = {
|
||||||
totalAssets: vehicles.length,
|
totalAssets: vehicles.length,
|
||||||
operating: {
|
operating: {
|
||||||
@@ -525,11 +526,11 @@ app.get('/summary', async (c) => {
|
|||||||
abnormal: vehicles.filter((v) => v.status === 'Abnormal').length,
|
abnormal: vehicles.filter((v) => v.status === 'Abnormal').length,
|
||||||
},
|
},
|
||||||
pendingDelivery: vehicles.filter((v) => v.status === 'Pending').length,
|
pendingDelivery: vehicles.filter((v) => v.status === 'Pending').length,
|
||||||
weeklyNew: weekly.weeklyNew,
|
weeklyNew: 0,
|
||||||
weeklyRemoved: weekly.weeklyRemoved,
|
weeklyRemoved: 0,
|
||||||
weeklyDelivered: weekly.weeklyDelivered,
|
weeklyDelivered: [...weeklyIds.delivered].filter(id => vehicleIds.has(id)).length,
|
||||||
weeklyReturned: weekly.weeklyReturned,
|
weeklyReturned: [...weeklyIds.returned].filter(id => vehicleIds.has(id)).length,
|
||||||
weeklyReplaced: weekly.weeklyReplaced,
|
weeklyReplaced: [...weeklyIds.replaced].filter(id => vehicleIds.has(id)).length,
|
||||||
};
|
};
|
||||||
return c.json(summary);
|
return c.json(summary);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user