mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-02-04 03:35:09 -05:00
Add method to check for missing traffic hours.
This commit is contained in:
committed by
Brian Simpson
parent
f8dd9e224c
commit
704902b6f5
@@ -368,6 +368,19 @@ def get_traffic_last_modified():
|
||||
return datetime.datetime.min
|
||||
|
||||
|
||||
@memoize("missing_traffic", time=60 * 10)
|
||||
def get_missing_traffic(start, end):
|
||||
"""Check for missing hourly traffic between start and end."""
|
||||
|
||||
# NOTE: start, end must be UTC time without tzinfo
|
||||
time_points = get_time_points('hour', start, end)
|
||||
q = (Session.query(SitewidePageviews.date)
|
||||
.filter(SitewidePageviews.interval == "hour")
|
||||
.filter(SitewidePageviews.date.in_(time_points)))
|
||||
found = [t for (t,) in q]
|
||||
return [t for t in time_points if t not in found]
|
||||
|
||||
|
||||
class SitewidePageviews(Base):
|
||||
"""Pageviews across all areas of the site."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user