Browse Source

fix: show route waypointCount from list API

Route list returns waypointCount, not waypoints[]. Cards were
always rendering 0 because the frontend only checked the array.
main
xiaosi 2 weeks ago
parent
commit
541c3a283c
  1. 24
      src/views/TasksView/TasksView.vue

24
src/views/TasksView/TasksView.vue

@ -502,14 +502,28 @@ async function load() {
return toExecutionRecord(r, taskNames.get(r.taskId), '', video ? { id: String(video.id), status: video.status } : null) return toExecutionRecord(r, taskNames.get(r.taskId), '', video ? { id: String(video.id), status: video.status } : null)
}) })
routes.value = (routePage?.records || []).map((r, i) => ({
routes.value = (routePage?.records || []).map((r, i) => {
// waypointCount waypoints[]
const count = Number(r.waypointCount ?? r.waypoint_count)
const fromList = Array.isArray(r.waypoints) ? r.waypoints.length : NaN
const waypoints = Number.isFinite(fromList)
? fromList
: (Number.isFinite(count) ? count : 0)
const distance = Array.isArray(r.waypoints) && r.waypoints.length
? `${routeDistance(r.waypoints.map((p) => ({
longitude: Number(p.longitude),
latitude: Number(p.latitude),
}))).toFixed(1)} km`
: (r.distance || '--')
return {
id: String(r.id), id: String(r.id),
name: r.name, name: r.name,
waypoints: Array.isArray(r.waypoints) ? r.waypoints.length : 0,
distance: Array.isArray(r.waypoints) ? `${routeDistance(r.waypoints.map((p) => ({ longitude: Number(p.longitude), latitude: Number(p.latitude) })) ).toFixed(1)} km` : '--',
waypoints,
distance,
collectedAt: fmtTime(r.createdAt), collectedAt: fmtTime(r.createdAt),
mapClass: i % 2 === 0 ? 'route-a' : 'route-c'
}))
mapClass: i % 2 === 0 ? 'route-a' : 'route-c',
}
})
const hasActiveExecution = (execPage?.records || []).some((r) => ['pending', 'running'].includes(r.status)) const hasActiveExecution = (execPage?.records || []).some((r) => ['pending', 'running'].includes(r.status))
if (hasActiveExecution && !refreshTimer) refreshTimer = window.setInterval(load, 5000) if (hasActiveExecution && !refreshTimer) refreshTimer = window.setInterval(load, 5000)
if (!hasActiveExecution && refreshTimer) { if (!hasActiveExecution && refreshTimer) {

Loading…
Cancel
Save