forked from rDrama/rDrama
remove unnecessary .all()
parent
a3a29408f4
commit
ed34558f33
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -514,7 +514,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
|
|||
sanitized = audio_sub_regex.sub(r'<audio controls preload="none" src="\1"></audio>', 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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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}`.")
|
||||
|
|
|
@ -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}"')
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue