From bc41bb5584a689218a2079a3125f8cb1aa97a1d5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 2 Jul 2022 11:29:01 +0200 Subject: [PATCH] testing, pls ignore --- files/helpers/cron.py | 5 +++-- files/routes/admin.py | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 2249fccc9..7c46fdc8e 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -8,7 +8,7 @@ import files.helpers.stats as stats import files.helpers.awards as awards import files.routes.static as route_static from files.routes.subs import sub_inactive_purge_task -from files.routes.admin import give_monthly_marseybux_task +from files.routes.admin import give_monthly_marseybux_task, migrate_polls from sys import stdout @@ -33,7 +33,8 @@ def cron(every_5m, every_1h, every_1d, every_1mo): sub_inactive_purge_task() if every_1mo: - give_monthly_marseybux_task() + #give_monthly_marseybux_task() + migrate_polls() g.db.commit() g.db.close() diff --git a/files/routes/admin.py b/files/routes/admin.py index c59a96c1c..4b7b154f2 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -50,6 +50,31 @@ def give_monthly_marseybux_task(): return True +def migrate_polls(): + + polls = g.db.query(Comment).filter_by(author_id=6176, parent_comment_id=None, parent_submission=77232).all() + for c in polls: + print(c.id, flush=True) + option = SubmissionOption( + submission_id=c.parent_submission, + body_html=c.body_html, + exclusive = False + ) + g.db.add(option) + g.db.flush() + votes = g.db.query(CommentVote).filter_by(comment_id=c.id).all() + for vote in votes: + o_vote = SubmissionOptionVote( + option_id=option.id, + user_id=vote.user_id, + submission_id=c.parent_submission, + ) + g.db.add(o_vote) + g.db.delete(vote) + g.db.delete(c) + + g.db.commit() + @app.post('/kippy') @admin_level_required(3) def kippy(v):