Aevann 2023-05-07 22:36:59 +03:00
parent 095e1d917c
commit 4056ce1e91
1 changed files with 3 additions and 3 deletions

View File

@ -38,11 +38,11 @@ def sort_objects(sort, objects, cls):
elif sort == "comments" and cls.__name__ == "Submission": elif sort == "comments" and cls.__name__ == "Submission":
return objects.order_by(cls.comment_count.desc(), cls.created_utc.desc()) return objects.order_by(cls.comment_count.desc(), cls.created_utc.desc())
elif sort == "subscriptions" and cls.__name__ == "Submission": elif sort == "subscriptions" and cls.__name__ == "Submission":
return objects.outerjoin(Subscription).group_by(cls.id).order_by(func.count(Subscription.submission_id).desc(), cls.created_utc.desc()) return objects.outerjoin(Subscription, Subscription.submission_id == cls.id).group_by(cls.id).order_by(func.count(Subscription.submission_id).desc(), cls.created_utc.desc())
elif sort == "saves" and cls.__name__ == "Submission": elif sort == "saves" and cls.__name__ == "Submission":
return objects.outerjoin(SaveRelationship).group_by(cls.id).order_by(func.count(SaveRelationship.submission_id).desc(), cls.created_utc.desc()) return objects.outerjoin(SaveRelationship, SaveRelationship.submission_id == cls.id).group_by(cls.id).order_by(func.count(SaveRelationship.submission_id).desc(), cls.created_utc.desc())
elif sort == "saves" and cls.__name__ == "Comment": elif sort == "saves" and cls.__name__ == "Comment":
return objects.outerjoin(CommentSaveRelationship).group_by(cls.id).order_by(func.count(CommentSaveRelationship.comment_id).desc(), cls.created_utc.desc()) return objects.outerjoin(CommentSaveRelationship, CommentSaveRelationship.comment_id == cls.id).group_by(cls.id).order_by(func.count(CommentSaveRelationship.comment_id).desc(), cls.created_utc.desc())
elif sort == "new": elif sort == "new":
return objects.order_by(cls.created_utc.desc()) return objects.order_by(cls.created_utc.desc())
elif sort == "old": elif sort == "old":