Browse Source

Fixed train info cache

python3 python3
Dan Cojocaru 3 years ago
parent
commit
cc7246facd
Signed by: kbruen
GPG Key ID: 818A889458EDC937
  1. 6
      server/server/v2/v2.py

6
server/server/v2/v2.py

@ -1,4 +1,4 @@
from datetime import datetime
from datetime import date, datetime
import json
from flask import Blueprint, jsonify, request
from flask.helpers import url_for
@ -55,8 +55,8 @@ def get_train_info(train_no: str):
db.on_train_data(result)
return result
if (train_no, use_yesterday) not in train_data_cache:
train_data_cache[(train_no, use_yesterday)] = CachedData(get_data, validity=1000 * 30)
data, fetch_time = train_data_cache[(train_no, use_yesterday)]()
train_data_cache[(train_no, use_yesterday or date_override)] = CachedData(get_data, validity=1000 * 30)
data, fetch_time = train_data_cache[(train_no, use_yesterday or date_override)]()
data['$schema'] = get_hostname() + url_for('.get_train_info_schema')
validate(data, schema=TRAIN_INFO_SCHEMA['v2'])
resp = jsonify(data)

Loading…
Cancel
Save