add short train types

This commit is contained in:
Milan Pässler 2020-09-11 19:44:31 +02:00
parent 3c4a0fc9c8
commit 688c782485
2 changed files with 6 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import asyncdispatch
var trainTypes = initTable[string, string]()
var trainTypesShort = initTable[string, string]()
proc fetchTrainTypes() {.async.} =
var client = newAsyncHttpClient()
@ -17,6 +18,8 @@ proc fetchTrainTypes() {.async.} =
for key, info in pairs(data):
if info{"type"}.getStr != "" and info{"type"}.getStr != "EC" and info{"type"}.getStr != "IC":
trainTypes[key] = info{"type"}.getStr
if info{"short"}.getStr != "":
trainTypesShort[key] = info{"short"}.getStr
asyncCheck fetchTrainTypes()
@ -46,6 +49,8 @@ proc parseLine*(common: CommonData, i: int): Option[Line] =
if res.productName == "IC" or res.productName == "ICE" or res.productName == "EC" or res.productName == "ECE":
if trainTypes.contains(res.tripNum) and trainTypes[res.tripNum] != res.productName:
res.trainType = some(trainTypes[res.tripNum])
if trainTypesShort.contains(res.tripNum):
res.trainTypeShort = some(trainTypesShort[res.tripNum])
if line.nameS.isSome and (res.product == bus or res.product == tram or res.product == ferry):
res.name = line.nameS.get

View file

@ -89,6 +89,7 @@ type
operator*: Option[Operator]
additionalName*: Option[string]
trainType*: Option[string]
trainTypeShort*: Option[string]
Operator* = object
id*: string