diff --git a/files/classes/comment.py b/files/classes/comment.py index 7cb0d6137..3ccf1c0e7 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -134,7 +134,7 @@ class Comment(Base): @lazy def total_choice_voted(self, v): if v: - return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).count() + return g.db.query(CommentVote.comment_id).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first() return False @property @@ -423,7 +423,7 @@ class Comment(Base): if self.choices: curr = self.total_choice_voted(v) - if curr: curr = " value=" + str(curr[0].comment_id) + if curr: curr = " value=" + str(curr.comment_id) else: curr = '' body += f'' diff --git a/files/classes/submission.py b/files/classes/submission.py index a9a7abe22..584259fb2 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -127,7 +127,7 @@ class Submission(Base): @lazy def total_choice_voted(self, v): if v and self.choices: - return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).count() + return g.db.query(CommentVote.comment_id).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first() return False @lazy @@ -417,7 +417,7 @@ class Submission(Base): if self.choices: curr = self.total_choice_voted(v) - if curr: curr = " value=" + str(curr[0].comment_id) + if curr: curr = " value=" + str(curr.comment_id) else: curr = '' body += f''