From 0d795b7c6493dbea7f2f1942f283dc16a06e9d41 Mon Sep 17 00:00:00 2001 From: Daoud Clarke Date: Fri, 29 Sep 2023 21:27:32 +0100 Subject: [PATCH] Fix bugs with date method --- mwmbl/crawler/stats.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mwmbl/crawler/stats.py b/mwmbl/crawler/stats.py index eb0efca..69e7a99 100644 --- a/mwmbl/crawler/stats.py +++ b/mwmbl/crawler/stats.py @@ -36,7 +36,7 @@ class StatsManager: num_crawled_urls = sum(1 for item in hashed_batch.items if item.content is not None) - url_count_key = URL_DATE_COUNT_KEY.format(date=date_time.date) + url_count_key = URL_DATE_COUNT_KEY.format(date=date_time.date()) self.redis.incrby(url_count_key, num_crawled_urls) self.redis.expire(url_count_key, EXPIRE_SECONDS) @@ -45,11 +45,11 @@ class StatsManager: self.redis.incrby(hour_key, num_crawled_urls) self.redis.expire(hour_key, EXPIRE_SECONDS) - user_count_key = USER_COUNT_KEY.format(date=date_time.date) + user_count_key = USER_COUNT_KEY.format(date=date_time.date()) self.redis.zincrby(user_count_key, num_crawled_urls, hashed_batch.user_id_hash) self.redis.expire(user_count_key, EXPIRE_SECONDS) - host_key = HOST_COUNT_KEY.format(date=date_time.date) + host_key = HOST_COUNT_KEY.format(date=date_time.date()) for item in hashed_batch.items: if item.content is None: continue @@ -76,10 +76,10 @@ class StatsManager: hour_count = 0 hour_counts.append(hour_count) - user_count_key = USER_COUNT_KEY.format(date=date_time.date) + user_count_key = USER_COUNT_KEY.format(date=date_time.date()) user_counts = self.redis.zrevrange(user_count_key, 0, 100, withscores=True) - host_key = HOST_COUNT_KEY.format(date=date_time.date) + host_key = HOST_COUNT_KEY.format(date=date_time.date()) host_counts = self.redis.zrevrange(host_key, 0, 100, withscores=True) return MwmblStats(