Move 'deleted_utc' into 'state_user_deleted_utc' and change types.
This commit is contained in:
parent
e03eef1a12
commit
5271e7c943
24 changed files with 141 additions and 83 deletions
|
@ -149,7 +149,7 @@ def api_comment(v):
|
|||
|
||||
existing = g.db.query(Comment.id).filter(
|
||||
Comment.author_id == v.id,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.parent_comment_id == parent_comment_id,
|
||||
Comment.parent_submission == parent_post.id,
|
||||
Comment.body_html == body_html
|
||||
|
@ -332,9 +332,9 @@ def edit_comment(cid, v):
|
|||
@auth_required
|
||||
def delete_comment(cid, v):
|
||||
c = get_comment(cid, v=v)
|
||||
if c.deleted_utc: abort(409)
|
||||
if c.state_user_deleted_utc: abort(409)
|
||||
if c.author_id != v.id: abort(403)
|
||||
c.deleted_utc = int(time.time())
|
||||
c.state_user_deleted_utc = time.time()
|
||||
# TODO: update stateful counters
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
|
@ -346,9 +346,9 @@ def delete_comment(cid, v):
|
|||
@auth_required
|
||||
def undelete_comment(cid, v):
|
||||
c = get_comment(cid, v=v)
|
||||
if not c.deleted_utc: abort(409)
|
||||
if not c.state_user_deleted_utc: abort(409)
|
||||
if c.author_id != v.id: abort(403)
|
||||
c.deleted_utc = 0
|
||||
c.state_user_deleted_utc = None
|
||||
# TODO: update stateful counters
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
|
|
|
@ -27,7 +27,7 @@ def unread(v):
|
|||
Notification.read == False,
|
||||
Notification.user_id == v.id,
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.author_id != AUTOJANNY_ID,
|
||||
).order_by(Notification.created_utc.desc()).all()
|
||||
|
||||
|
@ -101,7 +101,7 @@ def notifications(v):
|
|||
comments = g.db.query(Comment, Notification).join(Notification, Notification.comment_id == Comment.id).filter(
|
||||
Notification.user_id == v.id,
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.author_id != AUTOJANNY_ID,
|
||||
Comment.body_html.notlike('%<p>New site mention: <a href="https://old.reddit.com/r/%')
|
||||
).order_by(Notification.created_utc.desc())
|
||||
|
@ -250,7 +250,7 @@ def changelog(v):
|
|||
|
||||
@app.get("/random_post")
|
||||
def random_post():
|
||||
p = g.db.query(Submission.id).filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False).order_by(func.random()).first()
|
||||
p = g.db.query(Submission.id).filter(Submission.state_user_deleted_utc == None, Submission.is_banned == False, Submission.private == False).order_by(func.random()).first()
|
||||
|
||||
if p: p = p[0]
|
||||
else: abort(404)
|
||||
|
@ -308,7 +308,7 @@ def get_comments_idlist(page=1, v=None, sort="new", t="all", gt=0, lt=0):
|
|||
comments = comments.filter(
|
||||
Comment.author_id.notin_(v.userblocks),
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Submission.private == False, # comment parent post not private
|
||||
User.shadowbanned == None, # comment author not shadowbanned
|
||||
Comment.filter_state.notin_(('filtered', 'removed')),
|
||||
|
|
|
@ -428,7 +428,7 @@ def api_is_repost():
|
|||
search_url = sql_ilike_clean(url)
|
||||
repost = g.db.query(Submission).filter(
|
||||
Submission.url.ilike(search_url),
|
||||
Submission.deleted_utc == 0,
|
||||
Submission.state_user_deleted_utc == None,
|
||||
Submission.is_banned == False
|
||||
).first()
|
||||
if repost: return {'permalink': repost.permalink}
|
||||
|
@ -494,7 +494,7 @@ def _duplicate_check(search_url:Optional[str]) -> Optional[werkzeug.wrappers.Res
|
|||
if not search_url: return None
|
||||
repost = g.db.query(Submission).filter(
|
||||
func.lower(Submission.url) == search_url.lower(),
|
||||
Submission.deleted_utc == 0,
|
||||
Submission.state_user_deleted_utc == None,
|
||||
Submission.is_banned == False
|
||||
).first()
|
||||
if repost and SITE != 'localhost':
|
||||
|
@ -507,7 +507,7 @@ def _duplicate_check2(
|
|||
validated_post:validators.ValidatedSubmissionLike) -> Optional[werkzeug.wrappers.Response]:
|
||||
dup = g.db.query(Submission).filter(
|
||||
Submission.author_id == user_id,
|
||||
Submission.deleted_utc == 0,
|
||||
Submission.state_user_deleted_utc == None,
|
||||
Submission.title == validated_post.title,
|
||||
Submission.url == validated_post.url,
|
||||
Submission.body == validated_post.body
|
||||
|
@ -603,7 +603,7 @@ def delete_post_pid(pid, v):
|
|||
if post.author_id != v.id:
|
||||
abort(403)
|
||||
|
||||
post.deleted_utc = int(time.time())
|
||||
post.state_user_deleted_utc = datetime.now()
|
||||
post.is_pinned = False
|
||||
post.stickied = None
|
||||
|
||||
|
@ -621,7 +621,7 @@ def delete_post_pid(pid, v):
|
|||
def undelete_post_pid(pid, v):
|
||||
post = get_post(pid)
|
||||
if post.author_id != v.id: abort(403)
|
||||
post.deleted_utc = 0
|
||||
post.state_user_deleted_utc = None
|
||||
|
||||
g.db.add(post)
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ def searchposts(v):
|
|||
if not (v and v.paid_dues): posts = posts.filter_by(club=False)
|
||||
|
||||
if v and v.admin_level < 2:
|
||||
posts = posts.filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False, Submission.author_id.notin_(v.userblocks))
|
||||
posts = posts.filter(Submission.state_user_deleted_utc == None, Submission.is_banned == False, Submission.private == False, Submission.author_id.notin_(v.userblocks))
|
||||
elif not v:
|
||||
posts = posts.filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False)
|
||||
posts = posts.filter(Submission.state_user_deleted_utc == None, Submission.is_banned == False, Submission.private == False)
|
||||
|
||||
|
||||
if 'author' in criteria:
|
||||
|
@ -168,10 +168,10 @@ def searchcomments(v):
|
|||
|
||||
if v and v.admin_level < 2:
|
||||
private = [x[0] for x in g.db.query(Submission.id).filter(Submission.private == True).all()]
|
||||
comments = comments.filter(Comment.author_id.notin_(v.userblocks), Comment.is_banned==False, Comment.deleted_utc == 0, Comment.parent_submission.notin_(private))
|
||||
comments = comments.filter(Comment.author_id.notin_(v.userblocks), Comment.is_banned==False, Comment.state_user_deleted_utc == None, Comment.parent_submission.notin_(private))
|
||||
elif not v:
|
||||
private = [x[0] for x in g.db.query(Submission.id).filter(Submission.private == True).all()]
|
||||
comments = comments.filter(Comment.is_banned==False, Comment.deleted_utc == 0, Comment.parent_submission.notin_(private))
|
||||
comments = comments.filter(Comment.is_banned==False, Comment.state_user_deleted_utc == None, Comment.parent_submission.notin_(private))
|
||||
|
||||
|
||||
if not (v and v.paid_dues):
|
||||
|
|
|
@ -77,14 +77,14 @@ def participation_stats(v):
|
|||
"signups last 24h": users.filter(User.created_utc > day).count(),
|
||||
"total posts": submissions.count(),
|
||||
"posting users": g.db.query(Submission.author_id).distinct().count(),
|
||||
"listed posts": submissions.filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
|
||||
"listed posts": submissions.filter_by(is_banned=False).filter(Submission.state_user_deleted_utc == None).count(),
|
||||
"removed posts (by admins)": submissions.filter_by(is_banned=True).count(),
|
||||
"deleted posts (by author)": submissions.filter(Submission.deleted_utc > 0).count(),
|
||||
"deleted posts (by author)": submissions.filter(Submission.state_user_deleted_utc != None).count(),
|
||||
"posts last 24h": submissions.filter(Submission.created_utc > day).count(),
|
||||
"total comments": comments.filter(Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||
"commenting users": g.db.query(Comment.author_id).distinct().count(),
|
||||
"removed comments (by admins)": comments.filter_by(is_banned=True).count(),
|
||||
"deleted comments (by author)": comments.filter(Comment.deleted_utc > 0).count(),
|
||||
"deleted comments (by author)": comments.filter(Comment.state_user_deleted_utc != None).count(),
|
||||
"comments last_24h": comments.filter(Comment.created_utc > day, Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||
"post votes": g.db.query(Vote.submission_id).count(),
|
||||
"post voting users": g.db.query(Vote.user_id).distinct().count(),
|
||||
|
|
|
@ -39,7 +39,7 @@ def upvoters_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -60,7 +60,7 @@ def upvoters_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -81,7 +81,7 @@ def downvoters_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==-1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==-1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -102,7 +102,7 @@ def downvoters_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==-1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==-1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -122,7 +122,7 @@ def upvoting_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -143,7 +143,7 @@ def upvoting_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -164,7 +164,7 @@ def downvoting_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==-1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==-1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -185,7 +185,7 @@ def downvoting_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==-1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==-1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -200,9 +200,9 @@ def downvoting_comments(v, username, uid):
|
|||
def upvoters(v, username):
|
||||
id = get_user(username).id
|
||||
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
|
@ -226,9 +226,9 @@ def upvoters(v, username):
|
|||
def downvoters(v, username):
|
||||
id = get_user(username).id
|
||||
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==-1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==-1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==-1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==-1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
|
@ -250,9 +250,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 == False, Submission.is_banned == False, Submission.deleted_utc == 0, 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, Submission.is_banned == False, Submission.state_user_deleted_utc == None, 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 == False, Comment.is_banned == False, Comment.deleted_utc == 0, 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, Comment.is_banned == False, Comment.state_user_deleted_utc == None, 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))
|
||||
|
||||
|
@ -274,9 +274,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 == False, Submission.is_banned == False, Submission.deleted_utc == 0, 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, Submission.is_banned == False, Submission.state_user_deleted_utc == None, 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 == False, Comment.is_banned == False, Comment.deleted_utc == 0, 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, Comment.is_banned == False, Comment.state_user_deleted_utc == None, 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))
|
||||
|
||||
|
@ -754,7 +754,7 @@ def u_username_comments(username, v=None):
|
|||
|
||||
if not v or (v.id != u.id and v.admin_level < 2):
|
||||
comments = comments.filter(
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.is_banned == False,
|
||||
Comment.ghost == False,
|
||||
(Comment.filter_state != 'filtered') & (Comment.filter_state != 'removed')
|
||||
|
|
|
@ -44,8 +44,7 @@ def get_duty(u: User) -> Optional[VolunteerDutyJanitor]:
|
|||
# find reported not-deleted comments not made by the current user
|
||||
reported_comments = g.db.query(Comment) \
|
||||
.where(Comment.filter_state == 'reported') \
|
||||
.where(Comment.deleted_utc == 0) \
|
||||
.where(Comment.is_approved == None) \
|
||||
.where(Comment.state_user_deleted_utc == None) \
|
||||
.where(Comment.author_id != u.id) \
|
||||
.with_entities(Comment.id)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue