Move game support updateAll to celery task

This commit is contained in:
rubenwardy 2022-06-25 04:47:38 +01:00
parent e86eb6a4b8
commit 78717b5eea
2 changed files with 12 additions and 6 deletions

@ -16,11 +16,10 @@
import os import os
import sys
from typing import List from typing import List
import requests import requests
from celery import group from celery import group, uuid
from flask import redirect, url_for, flash, current_app, jsonify from flask import redirect, url_for, flash, current_app, jsonify
from sqlalchemy import or_, and_ from sqlalchemy import or_, and_
@ -29,7 +28,7 @@ from app.models import PackageRelease, db, Package, PackageState, PackageScreens
NotificationType, PackageUpdateConfig, License, UserRank, PackageType, PackageGameSupport NotificationType, PackageUpdateConfig, License, UserRank, PackageType, PackageGameSupport
from app.tasks.emails import send_pending_digests from app.tasks.emails import send_pending_digests
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, check_for_updates from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, check_for_updates, updateAllGameSupport
from app.utils import addNotification, get_system_user from app.utils import addNotification, get_system_user
from app.utils.image import get_image_size from app.utils.image import get_image_size
@ -328,9 +327,9 @@ def update_screenshot_sizes():
@action("Detect game support") @action("Detect game support")
def detect_game_support(): def detect_game_support():
resolver = GameSupportResolver(db.session) task_id = uuid()
resolver.update_all() updateAllGameSupport.apply_async((), task_id=task_id)
db.session.commit() return redirect(url_for("tasks.check", id=task_id, r=url_for("admin.admin_page")))
@action("Send pending notif digests") @action("Send pending notif digests")

@ -76,6 +76,13 @@ def getMeta(urlstr, author):
return result return result
@celery.task()
def updateAllGameSupport():
resolver = GameSupportResolver(db.session)
resolver.update_all()
db.session.commit()
def postReleaseCheckUpdate(self, release: PackageRelease, path): def postReleaseCheckUpdate(self, release: PackageRelease, path):
try: try:
tree = build_tree(path, expected_type=ContentType[release.package.type.name], tree = build_tree(path, expected_type=ContentType[release.package.type.name],