same as last commit

pull/189/head
Aevann 2023-08-11 16:15:34 +03:00
parent 3306238d84
commit 3ec2038caf
19 changed files with 47 additions and 47 deletions

View File

@ -44,7 +44,7 @@ class OauthApp(Base):
items = items.order_by(cls.created_utc.desc())
items = items.offset(100*(page-1)).limit(100)
items = [x.id for x in items.all()]
items = [x.id for x in items]
return items, total

View File

@ -414,11 +414,11 @@ class User(Base):
@property
@lazy
def sub_blocks(self):
stealth = set([x[0] for x in g.db.query(Sub.name).filter_by(stealth=True).all()])
stealth = stealth - set([x[0] for x in g.db.query(SubJoin.sub).filter_by(user_id=self.id).all()])
stealth = set([x[0] for x in g.db.query(Sub.name).filter_by(stealth=True)])
stealth = stealth - set([x[0] for x in g.db.query(SubJoin.sub).filter_by(user_id=self.id)])
if self.chud == 1: stealth = stealth - {'chudrama'}
return list(stealth) + [x[0] for x in g.db.query(SubBlock.sub).filter_by(user_id=self.id).all()]
return list(stealth) + [x[0] for x in g.db.query(SubBlock.sub).filter_by(user_id=self.id)]
@lazy
def blocks(self, sub):
@ -431,7 +431,7 @@ class User(Base):
@property
@lazy
def all_follows(self):
return [x[0] for x in g.db.query(SubSubscription.sub).filter_by(user_id=self.id).all()]
return [x[0] for x in g.db.query(SubSubscription.sub).filter_by(user_id=self.id)]
@lazy
def follows(self, sub):
@ -560,7 +560,7 @@ class User(Base):
@lazy
def all_twoway_blocks(self):
return set([x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=self.id).all() + \
g.db.query(UserBlock.user_id).filter_by(target_id=self.id).all()])
g.db.query(UserBlock.user_id).filter_by(target_id=self.id)])
def validate_2fa(self, token):
@ -697,12 +697,12 @@ class User(Base):
@property
@lazy
def followed_users(self):
return [x[0] for x in g.db.query(Follow.target_id).filter_by(user_id=self.id).all()]
return [x[0] for x in g.db.query(Follow.target_id).filter_by(user_id=self.id)]
@property
@lazy
def followed_subs(self):
return [x[0] for x in g.db.query(SubSubscription.sub).filter_by(user_id=self.id).all()]
return [x[0] for x in g.db.query(SubSubscription.sub).filter_by(user_id=self.id)]
@property
@lazy
@ -859,7 +859,7 @@ class User(Base):
@property
@lazy
def moderated_subs(self):
return [x[0] for x in g.db.query(Mod.sub).filter_by(user_id=self.id).order_by(Mod.sub).all()]
return [x[0] for x in g.db.query(Mod.sub).filter_by(user_id=self.id).order_by(Mod.sub)]
@property
@lazy
@ -867,7 +867,7 @@ class User(Base):
return [x[0] for x in g.db.query(GroupMembership.group_name).filter(
GroupMembership.user_id == self.id,
GroupMembership.approved_utc != None,
).order_by(GroupMembership.group_name).all()]
).order_by(GroupMembership.group_name)]
@lazy
def has_follower(self, user):
@ -1016,7 +1016,7 @@ class User(Base):
@property
@lazy
def userblocks(self):
return [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=self.id).all()]
return [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=self.id)]
def get_relationship_count(self, relationship_cls):
# TODO: deduplicate (see routes/users.py)

View File

@ -508,7 +508,7 @@ def execute_under_siege(v, target, body, kind):
if v.age > threshold: return
unshadowbannedcels = [x[0] for x in g.db.query(ModAction.target_user_id).filter_by(kind='unshadowban').all()]
unshadowbannedcels = [x[0] for x in g.db.query(ModAction.target_user_id).filter_by(kind='unshadowban')]
if v.id in unshadowbannedcels: return
check_for_alts(v)

View File

@ -138,7 +138,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
notify_users.update(user_ids)
if SITE_NAME == "WPD" and 'daisy' in text:
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_SPECIFIC_WPD_COMMENTS']).all()]
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_SPECIFIC_WPD_COMMENTS'])]
notify_users.update(admin_ids)
@ -163,7 +163,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
return 'everyone'
elif i.group(1) == 'jannies':
group = None
member_ids = set([x[0] for x in g.db.query(User.id).filter(User.admin_level > 0, User.id != AEVANN_ID).all()])
member_ids = set([x[0] for x in g.db.query(User.id).filter(User.admin_level > 0, User.id != AEVANN_ID)])
coin_receivers.update(member_ids)
else:
group = g.db.get(Group, i.group(1))

View File

@ -16,7 +16,7 @@ def const_initialize():
db = db_session()
marseys_const = [x[0] for x in db.query(Emoji.name).filter(Emoji.kind=="Marsey", Emoji.submitter_id==None, Emoji.name!='chudsey').all()]
marseys_const = [x[0] for x in db.query(Emoji.name).filter(Emoji.kind=="Marsey", Emoji.submitter_id==None, Emoji.name!='chudsey')]
marseys_const2 = marseys_const + ['chudsey','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','exclamationpoint','period','questionmark']
marseys = db.query(Emoji).filter(Emoji.kind=="Marsey", Emoji.submitter_id==None).all()
for marsey in marseys:
@ -30,7 +30,7 @@ def const_initialize():
SNAPPY_KONGS = db.query(Emoji.name).filter(Emoji.kind=="Donkey Kong", Emoji.submitter_id==None).all()
SNAPPY_KONGS = [f':#{x[0]}:' for x in SNAPPY_KONGS]
STEALTH_HOLES = [x[0] for x in db.query(Sub.name).filter_by(stealth=True).all()]
STEALTH_HOLES = [x[0] for x in db.query(Sub.name).filter_by(stealth=True)]
db.commit()
db.close()

View File

@ -77,13 +77,13 @@ def _sub_inactive_purge_task():
active_holes = [x[0] for x in g.db.query(Post.sub).distinct() \
.filter(Post.sub != None, Post.created_utc > one_week_ago,
Post.private == False, Post.is_banned == False,
Post.deleted_utc == 0).all()]
Post.deleted_utc == 0)]
active_holes.extend(['changelog','countryclub','museumofrdrama','highrollerclub']) # holes immune from deletion
dead_holes = g.db.query(Sub).filter(Sub.name.notin_(active_holes)).all()
names = [x.name for x in dead_holes]
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_INACTIVITY_DELETION']).all()]
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_INACTIVITY_DELETION'])]
mods = g.db.query(Mod).filter(Mod.sub.in_(names)).all()
for x in mods:

View File

@ -586,7 +586,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
if g.v and g.v.admin_level >= PERMS["IGNORE_DOMAIN_BAN"]:
banned_domains = []
else:
banned_domains = [x.domain for x in g.db.query(BannedDomain.domain).all()]
banned_domains = [x.domain for x in g.db.query(BannedDomain.domain)]
for link in links:
#remove empty links

View File

@ -242,10 +242,10 @@ def revert_actions(v, username):
cutoff = int(time.time()) - 86400
posts = [x[0] for x in g.db.query(ModAction.target_post_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post').all()]
posts = [x[0] for x in g.db.query(ModAction.target_post_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post')]
posts = g.db.query(Post).filter(Post.id.in_(posts)).all()
comments = [x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_comment').all()]
comments = [x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_comment')]
comments = g.db.query(Comment).filter(Comment.id.in_(comments)).all()
for item in posts + comments:
@ -254,7 +254,7 @@ def revert_actions(v, username):
item.is_approved = v.id
g.db.add(item)
users = (x[0] for x in g.db.query(ModAction.target_user_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind.in_(('shadowban', 'ban_user'))).all())
users = (x[0] for x in g.db.query(ModAction.target_user_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind.in_(('shadowban', 'ban_user'))))
users = g.db.query(User).filter(User.id.in_(users)).all()
for user in users:

View File

@ -342,7 +342,7 @@ def comment(v):
push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c)
if c.level == 1 and posting_to_post:
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id).all()]
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id)]
notify_users.update(subscriber_ids)

View File

@ -98,7 +98,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
elif v:
posts = posts.filter(or_(Post.sub == None, Post.sub.notin_(v.sub_blocks)))
else:
stealth = [x[0] for x in g.db.query(Sub.name).filter_by(stealth=True).all()]
stealth = [x[0] for x in g.db.query(Sub.name).filter_by(stealth=True)]
posts = posts.filter(or_(Post.sub == None, Post.sub.notin_(stealth)))
if gt: posts = posts.filter(Post.created_utc > gt)

View File

@ -52,7 +52,7 @@ def create_group(v):
)
g.db.add(group_membership)
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id).all()]
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id)]
for admin in admins:
send_repeatable_notification(admin, f":!marseyparty: !{group} has been created by @{v.username} :marseyparty:")

View File

@ -87,7 +87,7 @@ def request_api_keys(v):
new_comment.top_comment_id = new_comment.id
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['APPS_MODERATION']).all()]
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['APPS_MODERATION'])]
for admin_id in admin_ids:
notif = Notification(comment_id=new_comment.id, user_id=admin_id)

View File

@ -129,7 +129,7 @@ def option_votes(option_id, v):
ups = g.db.query(PostOptionVote).filter_by(option_id=option_id).order_by(PostOptionVote.created_utc).all()
user_ids = [x[0] for x in g.db.query(PostOptionVote.user_id).filter_by(option_id=option_id).all()]
user_ids = [x[0] for x in g.db.query(PostOptionVote.user_id).filter_by(option_id=option_id)]
total_ts = g.db.query(func.sum(User.truescore)).filter(User.id.in_(user_ids)).scalar()
total_ts = format(total_ts, ",") if total_ts else '0'
@ -165,7 +165,7 @@ def option_votes_comment(option_id, v):
ups = g.db.query(CommentOptionVote).filter_by(option_id=option_id).order_by(CommentOptionVote.created_utc).all()
user_ids = [x[0] for x in g.db.query(CommentOptionVote.user_id).filter_by(option_id=option_id).all()]
user_ids = [x[0] for x in g.db.query(CommentOptionVote.user_id).filter_by(option_id=option_id)]
total_ts = g.db.query(func.sum(User.truescore)).filter(User.id.in_(user_ids)).scalar()
total_ts = format(total_ts, ",") if total_ts else '0'

View File

@ -85,7 +85,7 @@ def submit_get(v, sub=None):
sub = get_sub_by_name(sub, graceful=True)
if request.path.startswith('/h/') and not sub: abort(404)
SUBS = [x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()]
SUBS = [x[0] for x in g.db.query(Sub.name).order_by(Sub.name)]
return render_template("submit.html", SUBS=SUBS, v=v, sub=sub)
@ -125,12 +125,12 @@ def post_id(pid, v, anything=None, sub=None):
comments, output = get_comments_v_properties(v, None, Comment.parent_post == p.id, Comment.level < 10)
if sort == "hot":
pinned = [c[0] for c in comments.filter(Comment.stickied != None).order_by(Comment.created_utc.desc()).all()]
pinned = [c[0] for c in comments.filter(Comment.stickied != None).order_by(Comment.created_utc.desc())]
comments = comments.filter(Comment.stickied == None)
comments = comments.filter(Comment.level == 1)
comments = sort_objects(sort, comments, Comment)
comments = [c[0] for c in comments.all()]
comments = [c[0] for c in comments]
else:
comments = g.db.query(Comment).filter(Comment.parent_post == p.id)
@ -216,7 +216,7 @@ def view_more(v, pid, sort, offset):
comments = comments.filter(Comment.level == 1)
comments = sort_objects(sort, comments, Comment)
comments = [c[0] for c in comments.all()]
comments = [c[0] for c in comments]
else:
comments = g.db.query(Comment).filter(
Comment.parent_post == pid,
@ -265,7 +265,7 @@ def more_comments(v, cid):
# output is needed: see comments.py
comments, output = get_comments_v_properties(v, None, Comment.top_comment_id == tcid, Comment.level > 9)
comments = comments.filter(Comment.parent_comment_id == cid)
comments = [c[0] for c in comments.all()]
comments = [c[0] for c in comments]
else:
c = get_comment(cid)
comments = c.replies(sort=request.values.get('sort'))

View File

@ -44,7 +44,7 @@ def get_alt_graph_ids(uid):
)
alt_graph_cte = alt_graph_cte.union(alt_graph_cte_inner)
return set([x[0] for x in g.db.query(User.id).filter(User.id == alt_graph_cte.c.user_id, User.id != uid).all()])
return set([x[0] for x in g.db.query(User.id).filter(User.id == alt_graph_cte.c.user_id, User.id != uid)])
def get_alt_graph(uid):
alt_ids = get_alt_graph_ids(uid)
@ -64,7 +64,7 @@ def add_alt(user1, user2):
def check_for_alts(current, include_current_session=False):
current_id = current.id
ids = [x[0] for x in g.db.query(User.id).all()]
ids = [x[0] for x in g.db.query(User.id)]
past_accs = set(session.get("history", [])) if include_current_session else set()
for past_id in list(past_accs):

View File

@ -240,7 +240,7 @@ def searchcomments(v):
comments = apply_time_filter(t, comments, Comment)
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
private = [x[0] for x in g.db.query(Post.id).filter(Post.private == True).all()]
private = [x[0] for x in g.db.query(Post.id).filter(Post.private == True)]
comments = comments.filter(
Comment.is_banned==False,

View File

@ -203,7 +203,7 @@ def log(v):
total = actions.count()
actions = actions.order_by(ModAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all()
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE']).order_by(User.username).all()]
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE']).order_by(User.username)]
return render_template("log.html", v=v, admins=admins, types=types, admin=admin, type=kind, actions=actions, total=total, page=page, single_user_url='admin')
@ -222,7 +222,7 @@ def log_item(id, v):
if action.kind in MODACTION_PRIVILEGED_TYPES and v.admin_level < PERMS['USER_SHADOWBAN']:
abort(404)
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE']).all()]
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE'])]
if v.admin_level >= PERMS['USER_SHADOWBAN']:
if v.admin_level >= PERMS['PROGSTACK']:
@ -294,7 +294,7 @@ def submit_contact(v):
execute_under_siege(v, new_comment, new_comment.body_html, 'modmail')
new_comment.top_comment_id = new_comment.id
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL']).all()]
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'])]
if SITE == 'watchpeopledie.tv' and AEVANN_ID in admin_ids:
admin_ids.remove(AEVANN_ID)

View File

@ -392,7 +392,7 @@ def create_sub2(v):
mod = Mod(user_id=v.id, sub=sub.name)
g.db.add(mod)
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id).all()]
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id)]
for admin in admins:
send_repeatable_notification(admin, f":!marseyparty: /h/{sub} has been created by @{v.username} :marseyparty:")
@ -884,8 +884,8 @@ def hole_log(v, sub):
total = actions.count()
actions = actions.order_by(SubAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all()
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name).all()]
mods = [x[0] for x in g.db.query(User.username).filter(User.id.in_(mods)).order_by(User.username).all()]
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name)]
mods = [x[0] for x in g.db.query(User.username).filter(User.id.in_(mods)).order_by(User.username)]
return render_template("log.html", v=v, admins=mods, types=types, admin=mod, type=kind, actions=actions, total=total, page=page, sub=sub, single_user_url='mod')
@ -904,8 +904,8 @@ def hole_log_item(id, v, sub):
if not action: abort(404)
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name).all()]
mods = [x[0] for x in g.db.query(User.username).filter(User.id.in_(mods)).order_by(User.username).all()]
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name)]
mods = [x[0] for x in g.db.query(User.username).filter(User.id.in_(mods)).order_by(User.username)]
types = SUBACTION_TYPES

View File

@ -39,7 +39,7 @@ def _add_profile_view(vid, uid):
stdout.flush()
def claim_rewards_all_users():
emails = [x[0] for x in g.db.query(Transaction.email).filter_by(claimed=None).all()]
emails = [x[0] for x in g.db.query(Transaction.email).filter_by(claimed=None)]
users = g.db.query(User).filter(User.email.in_(emails)).order_by(User.truescore.desc()).all()
for user in users:
transactions = g.db.query(Transaction).filter_by(email=user.email, claimed=None).all()
@ -384,7 +384,7 @@ def all_upvoters_downvoters(v, username, vote_dir, is_who_simps_hates):
total_items = sum(votes.values())
users = g.db.query(User).filter(User.id.in_(votes.keys()))
users = [(user, votes[user.id]) for user in users.all()]
users = [(user, votes[user.id]) for user in users]
users = sorted(users, key=lambda x: x[1], reverse=True)
try:
@ -753,7 +753,7 @@ def messagereply(v):
top_comment = c.top_comment
if top_comment.sentto == MODMAIL_ID:
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != v.id).all()]
admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != v.id)]
if SITE == 'watchpeopledie.tv' and AEVANN_ID in admin_ids:
admin_ids.remove(AEVANN_ID)