diff --git a/files/routes/admin.py b/files/routes/admin.py index 4be2e8591..e400eb2b8 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 dd7647211..c61e402c2 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 e02cae011..b90383512 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 d138fd706..681886179 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,