summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--forum/managers.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/forum/managers.py b/forum/managers.py
index ce67c237..ba174998 100644
--- a/forum/managers.py
+++ b/forum/managers.py
@@ -200,11 +200,11 @@ class VoteManager(models.Manager):
return 0
class FlaggedItemManager(models.Manager):
- COUNT_FLAGS_PER_DAY_BY_USER = "SELECT COUNT(*) FROM flagged_item WHERE user_id = %s AND DATE(flagged_at) = DATE(NOW())"
+ COUNT_FLAGS_PER_DAY_BY_USER = "SELECT COUNT(*) FROM flagged_item WHERE user_id = %s AND DATE(flagged_at) = %s"
def get_flagged_items_count_today(self, user):
if user is not None:
cursor = connection.cursor()
- cursor.execute(self.COUNT_FLAGS_PER_DAY_BY_USER, [user.id])
+ cursor.execute(self.COUNT_FLAGS_PER_DAY_BY_USER, [user.id, time.strftime("%Y-%m-%d", datetime.datetime.now().timetuple())])
row = cursor.fetchone()
return row[0]
@@ -212,7 +212,7 @@ class FlaggedItemManager(models.Manager):
return 0
class ReputeManager(models.Manager):
- COUNT_REPUTATION_PER_DAY_BY_USER = "SELECT SUM(positive)+SUM(negative) FROM repute WHERE user_id = %s AND (reputation_type=1 OR reputation_type=-8) AND DATE(reputed_at) = DATE(NOW())"
+ COUNT_REPUTATION_PER_DAY_BY_USER = "SELECT SUM(positive)+SUM(negative) FROM repute WHERE user_id = %s AND (reputation_type=1 OR reputation_type=-8) AND DATE(reputed_at) = %s"
def get_reputation_by_upvoted_today(self, user):
"""
For one user in one day, he can only earn rep till certain score (ep. +200)
@@ -221,7 +221,7 @@ class ReputeManager(models.Manager):
"""
if user is not None:
cursor = connection.cursor()
- cursor.execute(self.COUNT_REPUTATION_PER_DAY_BY_USER, [user.id])
+ cursor.execute(self.COUNT_REPUTATION_PER_DAY_BY_USER, [user.id, time.strftime("%Y-%m-%d", datetime.datetime.now().timetuple())])
row = cursor.fetchone()
return row[0]