From f724a74687557cc89aa5fe9bd9b02d2b0e27c7ef Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 18 Sep 2021 19:43:03 +0200 Subject: [PATCH] fsfs --- files/routes/admin.py | 4 ++-- files/routes/awards.py | 2 +- files/routes/front.py | 12 ++++++++---- files/routes/settings.py | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index 4be2e85917..e400eb2b83 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -185,7 +185,7 @@ def monthly(v): send_notification(NOTIFICATIONS_ACCOUNT, u, text) - g.db.bulk_save_objects(_awards) + g.db.add_all(_awards) g.db.commit() return {"message": "Monthly awards granted"} @@ -424,7 +424,7 @@ def badge_grant_post(v): kind=name )) - g.db.bulk_save_objects(_awards) + g.db.add_all(_awards) text = "You were given the following awards:\n\n" diff --git a/files/routes/awards.py b/files/routes/awards.py index dd76472115..c61e402c26 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -354,7 +354,7 @@ def admin_userawards_post(v): kind=key )) - g.db.bulk_save_objects(awards) + g.db.add_all(awards) text = "You were given the following awards:\n\n" for key, value in notify_awards.items(): diff --git a/files/routes/front.py b/files/routes/front.py index e02cae0119..b903835125 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -30,16 +30,18 @@ def notifications(v): notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() comments = [] - + notifs = [] + for index, x in enumerate(notifications): c = x.comment if x.read and index > 26: break elif not x.read: c.unread = True x.read = True - g.db.add(x) + notifs.append(x) comments.append(c) - + + g.db.add(notifs) g.db.commit() next_exists = (len(comments) > 25) @@ -58,15 +60,17 @@ def notifications(v): comments = get_comments(cids, v=v, load_parent=True) i = 0 + notifs = [] for x in notifications: try: if not x.read: comments[i].unread = True x.read = True - g.db.add(x) + notifs.append(x) except: continue i += 1 + g.db.add(notifs) g.db.commit() if not posts: diff --git a/files/routes/settings.py b/files/routes/settings.py index d138fd7064..6818861793 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -354,7 +354,7 @@ def gumroad(v): kind=name )) - g.db.bulk_save_objects(_awards) + g.db.add_all(_awards) if not v.has_badge(20+tier): new_badge = Badge(badge_id=20+tier,