Skip to content

Commit 0b6bdff

Browse files
committed
hotfix: add #4202
1 parent 97b2c48 commit 0b6bdff

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

source/jormungandr/jormungandr/olympic_site_params_manager.py

+15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
local_str_date_to_utc,
3636
date_to_timestamp,
3737
str_to_dt,
38+
str_datetime_utc_to_local,
3839
)
3940
import boto3
4041
from jormungandr import app
@@ -145,13 +146,27 @@ def get_json_content(self, s3_object):
145146
logger.exception('Error while loading file: {}'.format(s3_object.key))
146147
return {}
147148

149+
def add_metadata(self, json_content, s3_object):
150+
if s3_object:
151+
filename = ""
152+
try:
153+
filename = s3_object.key.split("/")[-1]
154+
except Exception:
155+
pass
156+
for key, value in json_content.items():
157+
value["metadata"] = {
158+
"last_load_at": str_datetime_utc_to_local(None, self.instance.timezone),
159+
"filename": filename,
160+
}
161+
148162
@cache.memoize(app.config[str('CACHE_CONFIGURATION')].get(str('FETCH_S3_DATA_TIMEOUT'), 24 * 60))
149163
def load_data(self, resource_s3_object):
150164
"""
151165
the POI conf is hidden in REDIS by the instance name, file name and Etag of the S3 object
152166
"""
153167
json_content = self.get_json_content(resource_s3_object.s3_object)
154168
self.str_datetime_time_stamp(json_content)
169+
self.add_metadata(json_content, resource_s3_object.s3_object)
155170
return json_content
156171

157172
@memory_cache.memoize(

0 commit comments

Comments
 (0)