Skip to content

Commit

Permalink
fix query to fetch comment for review
Browse files Browse the repository at this point in the history
  • Loading branch information
iambibhas committed Aug 3, 2020
1 parent 32661a4 commit 7b0de03
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion funnel/models/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ class CommentModeratorReport(UuidMixin, BaseMixin, db.Model):
def get_one(cls, exclude_user=None):
reports = cls.query.filter()
if exclude_user is not None:
reports = reports.filter(cls.user != exclude_user)
existing_reports = (
db.session.query(cls.id).filter_by(user_id=exclude_user.id).distinct()
)
reports = reports.filter(~cls.id.in_(existing_reports))

return reports.order_by(db.func.random()).first()


Expand Down

0 comments on commit 7b0de03

Please sign in to comment.