mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-14 17:38:04 -05:00
Fix VoteDetailsByDay.count_votes()
This was still using the old method of calling _rowkey (which took a date argument). The date needs to be converted to a datetime, and can then be used to call _rowkey_by_datetime(). I also switched to use .get_count() instead of manually counting the columns from the row, which should probably be faster.
This commit is contained in:
@@ -493,7 +493,11 @@ class VoteDetailsByDay(tdb_cassandra.View):
|
||||
|
||||
@classmethod
|
||||
def count_votes(cls, date):
|
||||
return sum(1 for x in cls._cf.xget(cls._rowkey(date)))
|
||||
"""Return the number of votes made on a particular date."""
|
||||
# convert the date to a datetime in the correct timezone
|
||||
date = datetime(date.year, date.month, date.day, tzinfo=cls.TIMEZONE)
|
||||
|
||||
return cls._cf.get_count(cls._rowkey_by_datetime(date))
|
||||
|
||||
|
||||
@tdb_cassandra.view_of(LinkVotesByAccount)
|
||||
|
||||
Reference in New Issue
Block a user