From 9cfa1bb5fa0c20d16efaaa0962febdbabbfc9ecf Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 1 Feb 2024 19:36:01 +0200 Subject: [PATCH] remove all duplicate tags --- files/routes/asset_submissions.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index 4b2d462d0..862caa7ba 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -21,13 +21,23 @@ def delete_unnecessary_tags(tags, name): if tag not in name and tag not in new_tags: new_tags.append(tag) - if not new_tags: abort(400, "Invalid tags!") + # if not new_tags: abort(400, "Invalid tags!") return ' '.join(new_tags) @app.get("/submit/marseys") @feature_required('EMOJI_SUBMISSIONS') def submit_marseys_redirect(): + emojis = g.db.query(Emoji).all() + + for emoji in emojis: + new_tags = delete_unnecessary_tags(emoji.tags, emoji.name) + if new_tags and new_tags != emoji.tags: + print(f'{emoji.name} Before: {emoji.tags}', flush=True) + print(f'{emoji.name} After: {new_tags}', flush=True) + emoji.tags = new_tags + g.db.add(emoji) + return redirect("/submit/emojis") @app.get("/submit/emojis")