Example #1
0
 def get_thread_karma(self):
     thread_ids = [t.id for t in self.threads]
     select = thread_upvotes.select(db.and_(
             thread_upvotes.c.thread_id.in_(thread_ids),
             thread_upvotes.c.user_id != self.id
         )
     )
     rs = db.engine.execute(select)
     return rs.rowcount
Example #2
0
 def get_comment_karma(self):
     """
     fetch the number of votes this user has had on his/her comments
     """
     comment_ids = [c.id for c in self.comments]
     select = comment_upvotes.select(db.and_(
             comment_upvotes.c.comment_id.in_(comment_ids),
             comment_upvotes.c.user_id != self.id
         )
     )
     rs = db.engine.execute(select)
     return rs.rowcount