aboutsummaryrefslogtreecommitdiff
path: root/app/tasks/forumtasks.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-12-25 19:49:17 +0000
committerrubenwardy <rw@rubenwardy.com>2018-12-25 19:49:17 +0000
commit0b83d2f2b5461c402120b089e2686c1ce4c63b25 (patch)
treef70972c9f8abf511d793633b35ff6dfa6947373e /app/tasks/forumtasks.py
parent21960f24047bdf64eff99ec955ff2229c49eff50 (diff)
downloadcheatdb-0b83d2f2b5461c402120b089e2686c1ce4c63b25.tar.xz
Add task to bulk import avatars from forum
Diffstat (limited to 'app/tasks/forumtasks.py')
-rw-r--r--app/tasks/forumtasks.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/tasks/forumtasks.py b/app/tasks/forumtasks.py
index 0a5f028..9e4cbfb 100644
--- a/app/tasks/forumtasks.py
+++ b/app/tasks/forumtasks.py
@@ -25,7 +25,8 @@ import urllib.request
from urllib.parse import urlparse, quote_plus
@celery.task()
-def checkForumAccount(username):
+def checkForumAccount(username, forceNoSave=False):
+ print("Checking " + username)
try:
profile = getProfile("https://forum.minetest.net", username)
except OSError:
@@ -52,9 +53,23 @@ def checkForumAccount(username):
user.profile_pic = pic
# Save
- if needsSaving:
+ if needsSaving and not forceNoSave:
db.session.commit()
+ return needsSaving
+
+@celery.task()
+def checkAllForumAccounts(forceNoSave=False):
+ needsSaving = False
+ query = User.query.filter(User.forums_username.isnot(None))
+ for user in query.all():
+ needsSaving = checkForumAccount(user.username) or needsSaving
+
+ if needsSaving and not forceNoSave:
+ db.session.commit()
+
+ return needsSaving
+
regex_tag = re.compile(r"\[([a-z0-9_]+)\]")
BANNED_NAMES = ["mod", "game", "old", "outdated", "wip", "api", "beta", "alpha", "git"]