Add recalc package scores admin action

This commit is contained in:
rubenwardy 2024-06-02 12:26:22 +01:00
parent 1eaa5d8767
commit 8db31ebfa9

@ -54,19 +54,6 @@ def del_stuck_releases():
db.session.commit() db.session.commit()
return redirect(url_for("admin.admin_page")) return redirect(url_for("admin.admin_page"))
@action("Import forum topic list")
def import_topic_list():
task = import_topic_list.delay()
return redirect(url_for("tasks.check", id=task.id, r=url_for("todo.topics")))
@action("Check all forum accounts")
def check_all_forum_accounts():
task = check_all_forum_accounts.delay()
return redirect(url_for("tasks.check", id=task.id, r=url_for("admin.admin_page")))
@action("Delete unused uploads") @action("Delete unused uploads")
def clean_uploads(): def clean_uploads():
upload_dir = current_app.config['UPLOAD_DIR'] upload_dir = current_app.config['UPLOAD_DIR']
@ -112,6 +99,29 @@ def del_mod_names():
return redirect(url_for("admin.admin_page")) return redirect(url_for("admin.admin_page"))
@action("Recalc package scores")
def recalc_scores():
for package in Package.query.all():
package.recalculate_score()
db.session.commit()
flash("Recalculated package scores", "success")
return redirect(url_for("admin.admin_page"))
@action("Import forum topic list")
def import_topic_list():
task = import_topic_list.delay()
return redirect(url_for("tasks.check", id=task.id, r=url_for("todo.topics")))
@action("Check all forum accounts")
def check_all_forum_accounts():
task = check_all_forum_accounts.delay()
return redirect(url_for("tasks.check", id=task.id, r=url_for("admin.admin_page")))
@action("Run update configs") @action("Run update configs")
def run_update_config(): def run_update_config():
check_for_updates.delay() check_for_updates.delay()