ctucx.git: oeffi-web

[nimlang] oeffisearch fork that works without javascript

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
import tables, json
import nimhafas
import ../types, ../cache_types

proc formatFullResponse* (cacheObj: CacheObject): JsonNode =
    var response = %* {
        "reqId":       cacheObj.reqId,
        "lastUpdated": cacheObj.lastUpdated,
        "params":      cacheObj.params,
        "journeys":    {}
      }

    for key, journey in pairs(cacheObj.journeys):
      response["journeys"].add(key, %* journey)
      delete(response["journeys"][key], "refreshToken")
      delete(response["journeys"][key], "cycle")
      for legKey, leg in pairs(journey.legs):
        delete(response["journeys"][key]["legs"][legKey], "cycle")
        delete(response["journeys"][key]["legs"][legKey], "tripId")

    return response