Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit aa78064

Browse files
Minor changes to user_daily_visits (#10324)
* Use fake time in tests in _get_start_of_day. * Change the inequality of last_seen in user_daily_visits Co-authored-by: Erik Johnston <[email protected]>
1 parent 225be77 commit aa78064

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

changelog.d/10324.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Minor change to the code that populates `user_daily_visits`.

synapse/storage/databases/main/metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def _get_start_of_day(self):
320320
"""
321321
Returns millisecond unixtime for start of UTC day.
322322
"""
323-
now = time.gmtime()
323+
now = time.gmtime(self._clock.time())
324324
today_start = calendar.timegm((now.tm_year, now.tm_mon, now.tm_mday, 0, 0, 0))
325325
return today_start * 1000
326326

@@ -352,7 +352,7 @@ def _generate_user_daily_visits(txn):
352352
) udv
353353
ON u.user_id = udv.user_id AND u.device_id=udv.device_id
354354
INNER JOIN users ON users.name=u.user_id
355-
WHERE last_seen > ? AND last_seen <= ?
355+
WHERE ? <= last_seen AND last_seen < ?
356356
AND udv.timestamp IS NULL AND users.is_guest=0
357357
AND users.appservice_id IS NULL
358358
GROUP BY u.user_id, u.device_id

0 commit comments

Comments
 (0)