Call-for-Code / Call-for-Code/Prometeo-Pyrrha

Fix issue where run_analytics() caches the timestamp key, causing Duplicate Record exceptions

Open
#119 0 comments 0 reactions 1 assignee Claimed by @JSegrave-IBM View on GitHub
bug developer
Dominant language
JavaScript
Stars
27
Forks
18
PR merge metrics
No merged PRs in 30d

Description

`run_analytics()` in GasExposureAnalytics.py is caching the timestamp key after the first time it's called, causing Duplicate Record exceptions on subsequent calls.

Root cause : there's a default argument in the method definition. Python default arguments are evaluated once when the function is defined, not each time the function is called. Hence the caching.

Also fixed in this PR:
* Add some defensive code around the timestamp key, to ensure it's always (a) in UTC time and (b) does not have a timezone suffix (because mariadb does not support timezone aware timestamp datatypes).
* Get the logging to respect the `LOGLEVEL` environment variable and consistently log against the filename, even if it changes (i.e. get rid of the hardcoded log names)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.