diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 1eb7d2956..a8ec98e6c 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -133,7 +133,7 @@ def execute_snappy(post, v): group_members = group.member_ids - for user in g.db.query(User).filter(User.id.in_(group_members)).all(): + for user in g.db.query(User).filter(User.id.in_(group_members)): user.pay_account('coins', 10) g.db.add(user) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index eee3a3343..60861c6ff 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -73,11 +73,11 @@ def notif_comment(text): replace_with = existing[0][0] replaced = [x[0] for x in existing[1:]] - for n in g.db.query(Notification).filter(Notification.comment_id.in_(replaced)).all(): + for n in g.db.query(Notification).filter(Notification.comment_id.in_(replaced)): n.comment_id = replace_with g.db.add(n) - for c in g.db.query(Comment).filter(Comment.id.in_(replaced)).all(): + for c in g.db.query(Comment).filter(Comment.id.in_(replaced)): g.db.delete(c) return replace_with diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index d45463b0b..7a82a7cf2 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -514,7 +514,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis sanitized = audio_sub_regex.sub(r'', sanitized) if count_emojis: - for emoji in g.db.query(Emoji).filter(Emoji.submitter_id==None, Emoji.name.in_(emojis_used)).all(): + for emoji in g.db.query(Emoji).filter(Emoji.submitter_id==None, Emoji.name.in_(emojis_used)): emoji.count += 1 g.db.add(emoji) @@ -649,7 +649,7 @@ def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False): title = render_emoji(title, emoji_regex2, golden, emojis_used, is_title=True) if count_emojis: - for emoji in g.db.query(Emoji).filter(Emoji.submitter_id==None, Emoji.name.in_(emojis_used)).all(): + for emoji in g.db.query(Emoji).filter(Emoji.submitter_id==None, Emoji.name.in_(emojis_used)): emoji.count += 1 g.db.add(emoji) diff --git a/files/routes/admin.py b/files/routes/admin.py index 57eb723a2..4e34405eb 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1766,7 +1766,7 @@ def admin_nuke_user(v): user=get_user(request.values.get("user")) - for post in g.db.query(Post).filter_by(author_id=user.id).all(): + for post in g.db.query(Post).filter_by(author_id=user.id): if post.is_banned: continue @@ -1774,7 +1774,7 @@ def admin_nuke_user(v): post.ban_reason = v.username g.db.add(post) - for comment in g.db.query(Comment).filter_by(author_id=user.id).all(): + for comment in g.db.query(Comment).filter_by(author_id=user.id): if comment.is_banned: continue @@ -1802,7 +1802,7 @@ def admin_nunuke_user(v): user=get_user(request.values.get("user")) - for post in g.db.query(Post).filter_by(author_id=user.id).all(): + for post in g.db.query(Post).filter_by(author_id=user.id): if not post.is_banned: continue @@ -1811,7 +1811,7 @@ def admin_nunuke_user(v): post.is_approved = v.id g.db.add(post) - for comment in g.db.query(Comment).filter_by(author_id=user.id).all(): + for comment in g.db.query(Comment).filter_by(author_id=user.id): if not comment.is_banned: continue diff --git a/files/routes/awards.py b/files/routes/awards.py index 89fbbe43d..c495b8c57 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -41,7 +41,7 @@ def shop(v): for val in AWARDS.values(): val["owned"] = 0 - for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.post_id == None, AwardRelationship.comment_id == None).all(): + for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.post_id == None, AwardRelationship.comment_id == None): if useraward.kind in AWARDS: AWARDS[useraward.kind]["owned"] += 1 for val in AWARDS.values(): @@ -448,7 +448,7 @@ def award_thing(v, thing_type, id): badge_grant(badge_id=84, user=author) elif kind == "unblockable": badge_grant(badge_id=87, user=author) - for block in g.db.query(UserBlock).filter_by(target_id=author.id).all(): g.db.delete(block) + for block in g.db.query(UserBlock).filter_by(target_id=author.id): g.db.delete(block) elif kind == "fish": badge_grant(badge_id=90, user=author) elif kind == "progressivestack": diff --git a/files/routes/oauth.py b/files/routes/oauth.py index 1faa1312f..6d2c6105f 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -114,7 +114,7 @@ def delete_oauth_app(v, aid): if app.author_id != v.id: abort(403) - for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): + for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id): g.db.delete(auth) g.db.delete(app) @@ -198,7 +198,7 @@ def admin_app_revoke(v, aid): app = g.db.get(OauthApp, aid) if app: - for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth) + for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id): g.db.delete(auth) if v.id != app.author.id: send_repeatable_notification(app.author.id, f"@{v.username} (a site admin) has revoked your application `{app.app_name}`.") @@ -227,7 +227,7 @@ def admin_app_reject(v, aid): app = g.db.get(OauthApp, aid) if app: - for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth) + for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id): g.db.delete(auth) if v.id != app.author.id: send_repeatable_notification(app.author.id, f"@{v.username} (a site admin) has rejected your application `{app.app_name}`.") diff --git a/files/routes/posts.py b/files/routes/posts.py index 5c23e031d..fd4458148 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -469,7 +469,7 @@ def submit_post(v, sub=None): url = normalize_url(url) if v.admin_level < PERMS["IGNORE_DOMAIN_BAN"]: - for x in g.db.query(BannedDomain).all(): + for x in g.db.query(BannedDomain): if url.startswith(x.domain): abort(400, f'Remove the banned link "{x.domain}" and try again!\nReason for link ban: "{x.reason}"') diff --git a/files/routes/users.py b/files/routes/users.py index a28e09820..b339a57c7 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -100,7 +100,7 @@ def claim_rewards_all_users(): print(f'@{user.username} rewards claimed successfully!', flush=True) - for user in g.db.query(User).options(load_only(User.id)).order_by(User.lifetimedonated.desc()).limit(10).all(): + for user in g.db.query(User).options(load_only(User.id)).order_by(User.lifetimedonated.desc()).limit(10): badge_grant(badge_id=294, user=user) def transfer_currency(v, username, currency_name, apply_tax):