aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-01-22 11:11:40 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-01-22 11:11:40 +0100
commit845a82d8d661e26d188f7a420de04e538323ae92 (patch)
treecd9345d37812072464f623ffd5a42d2066ddaeee
parentc8221c43a9c4ec00544ea7b03549f290bce7c0cf (diff)
downloadoeffi-web-845a82d8d661e26d188f7a420de04e538323ae92.tar.gz
oeffi-web-845a82d8d661e26d188f7a420de04e538323ae92.tar.bz2
oeffi-web-845a82d8d661e26d188f7a420de04e538323ae92.zip
journeyView: check if distance is a none
-rw-r--r--src/formaters/renderJourney.nim15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/formaters/renderJourney.nim b/src/formaters/renderJourney.nim
index 806b500..0a052ad 100644
--- a/src/formaters/renderJourney.nim
+++ b/src/formaters/renderJourney.nim
@@ -52,10 +52,17 @@ proc renderJourney*(data: CacheObject, id: string): JsonNode =
})
elif leg.isTransfer != false:
+ var distance: int
+
+ if not leg.distance.isNone:
+ distance = leg.distance.get
+ else:
+ distance = 0
+
result["LEGS"].add(%* {
"IS_TRANSFER": true,
"ARRIVAL_POINT": formatPoint(leg.arrival.point),
- "DISTANCE": leg.distance.get
+ "DISTANCE": distance
})
else:
@@ -78,10 +85,6 @@ proc renderJourney*(data: CacheObject, id: string): JsonNode =
"IS_CHANGE": true,
"DURATION": formatDuration(departureTime - lastArrivalTime)
})
-
- legDuration = arrivalTime - departureTime
-
- lastArrival = leg.arrival
if leg.line.get.product == nationalExp or leg.line.get.product == national or leg.line.get.product == regionalExp or leg.line.get.product == regional:
hasMarudorUrl = true
@@ -189,6 +192,8 @@ proc renderJourney*(data: CacheObject, id: string): JsonNode =
"PLATFORM_HAS_CHANGED": platformHasChanged
})
+ legDuration = arrivalTime - departureTime
+ lastArrival = leg.arrival
inc(changes)
result["LEGS"].add(%* {