From ec9797ff1879953708e3f8cdf0b3615570368b3d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 16 Feb 2022 00:54:17 +0200 Subject: [PATCH] f --- files/classes/comment.py | 2 +- files/classes/submission.py | 2 +- files/classes/user.py | 2 +- files/routes/search.py | 4 ++-- files/routes/users.py | 10 +++++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 270114c4b..bfde5189d 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -23,7 +23,7 @@ class Comment(Base): created_utc = Column(Integer) edited_utc = Column(Integer, default=0) is_banned = Column(Boolean, default=False) - ghost = Column(Boolean) + ghost = Column(Boolean, default=False) bannedfor = Column(Boolean) distinguish_level = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) diff --git a/files/classes/submission.py b/files/classes/submission.py index ca9a2ca89..ca1ab5f4b 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -25,7 +25,7 @@ class Submission(Base): thumburl = Column(String) is_banned = Column(Boolean, default=False) bannedfor = Column(Boolean) - ghost = Column(Boolean) + ghost = Column(Boolean, default=False) views = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) distinguish_level = Column(Integer, default=0) diff --git a/files/classes/user.py b/files/classes/user.py index d50e5f22e..6463efdcc 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -257,7 +257,7 @@ class User(Base): posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False) if not (v and (v.admin_level > 1 or v.id == self.id)): - posts = posts.filter_by(deleted_utc=0, is_banned=False, private=False, ghost=None) + posts = posts.filter_by(deleted_utc=0, is_banned=False, private=False, ghost=False) now = int(time.time()) if t == 'hour': diff --git a/files/routes/search.py b/files/routes/search.py index 38d39f866..d062eaf28 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -64,7 +64,7 @@ def searchposts(v): if 'author' in criteria: - posts = posts.filter(Submission.ghost == None) + posts = posts.filter(Submission.ghost == False) author = get_user(criteria['author']) if not author: return {"error": "User not found"} if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye: @@ -211,7 +211,7 @@ def searchcomments(v): comments = g.db.query(Comment.id).filter(Comment.parent_submission != None) if 'author' in criteria: - comments = comments.filter(Comment.ghost == None) + comments = comments.filter(Comment.ghost == False) author = get_user(criteria['author']) if not author: return {"error": "User not found"} if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye: diff --git a/files/routes/users.py b/files/routes/users.py index 39d73d4b0..7cad7207a 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -109,9 +109,9 @@ def downvoters(v, username): def upvoting(v, username): id = get_user(username).id - votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==None, Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() + votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==False, Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() - votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==None, CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() + votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==False, CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() votes = Counter(dict(votes)) + Counter(dict(votes2)) @@ -133,9 +133,9 @@ def upvoting(v, username): def downvoting(v, username): id = get_user(username).id - votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==None, Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() + votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==False, Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() - votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==None, CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() + votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==False, CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() votes = Counter(dict(votes)) + Counter(dict(votes2)) @@ -825,7 +825,7 @@ def u_username_comments(username, v=None): comments = g.db.query(Comment.id).filter(Comment.author_id == u.id, Comment.parent_submission != None) if not v or (v.id != u.id and v.admin_level == 0): - comments = comments.filter(Comment.deleted_utc == 0, Comment.is_banned == False, Comment.ghost == None) + comments = comments.filter(Comment.deleted_utc == 0, Comment.is_banned == False, Comment.ghost == False) now = int(time.time()) if t == 'hour':