
On Mon, Sep 03 2018, Jaroslav Klapalek wrote:
An error was found during the start of new month. To fix this I have changed the SQL query to use '%s' (unix time) instead of '%d' (day number).
How does this work? The SQL query is using relation between two tables based on the date. This relation is created using these parts of query:
"select num,date('now',-num || ' days')" as d from days d = date(c.time)
First line creates timestampes of last 7 days -- time is set to UTC midnight. Second line converts data in 'c.time' to date struct - BUT! Even here the time is set to midnight. This behaviour makes the relation possible.
How does it behave in app.py? Result of the query contains data that are ordered by time. Unfortunately this order is lost during recasting the data to list/dict (which are unordered). To solve this sorting is used. Sorting data with unix time is safe, because it is always increasing.
To highlight this change, 'days' variable is refactored to 'unix_days'.
Výborný - hned je mi to jasnější. Aplikováno. -M.