diff options
author | hrcerqueira <hrcerqueira@gmail.com> | 2010-01-20 20:05:41 +0000 |
---|---|---|
committer | hrcerqueira <hrcerqueira@gmail.com> | 2010-01-20 20:05:41 +0000 |
commit | 82219376960d443ee095e260c2f3bbdd2a6e625c (patch) | |
tree | 957d8707c6ecdb671084f8e22a7bba340734a9f4 /forum | |
parent | 8f3ebdb12a0c1c0371986b0bca6809c126fa69ab (diff) | |
download | askbot-82219376960d443ee095e260c2f3bbdd2a6e625c.tar.gz askbot-82219376960d443ee095e260c2f3bbdd2a6e625c.tar.bz2 askbot-82219376960d443ee095e260c2f3bbdd2a6e625c.zip |
Some more sql fixes, I'm prety that now osqa works with sqlite as well.
Diffstat (limited to 'forum')
-rw-r--r-- | forum/managers.py | 8 |
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]
|