diff --git a/backend/endpoints/tasks.py b/backend/endpoints/tasks.py new file mode 100644 index 000000000..32a4e6c57 --- /dev/null +++ b/backend/endpoints/tasks.py @@ -0,0 +1,15 @@ +from fastapi import APIRouter, Request + +from utils.oauth import protected_route +from tasks.update_mame_xml import update_mame_xml_task +from tasks.update_switch_titledb import update_switch_titledb_task + +router = APIRouter() + +@protected_route(router.post, "/tasks/run", ["tasks.run"]) +async def run_tasks(request: Request): + """Run all async tasks""" + await update_mame_xml_task.run() + await update_switch_titledb_task.run() + + return {"message": "All tasks run successfully!"} diff --git a/backend/endpoints/tests/test_heartbeat.py b/backend/endpoints/tests/test_heartbeat.py index b3ec96970..500bcc517 100644 --- a/backend/endpoints/tests/test_heartbeat.py +++ b/backend/endpoints/tests/test_heartbeat.py @@ -13,7 +13,7 @@ def test_heartbeat(): "WATCHER": { "ENABLED": True, "TITLE": "Rescan on filesystem change", - "MESSAGE": "Runs a scan when a change is detected in the library path, with a 5 minutes delay", + "MESSAGE": "Runs a scan when a change is detected in the library path, with a 5 minute delay", }, "SCHEDULER": { "RESCAN": { @@ -32,7 +32,7 @@ def test_heartbeat(): "ENABLED": True, "CRON": "0 5 * * *", "TITLE": "Scheduled MAME XML update", - "MESSAGE": "Updates the Nintedo MAME XML file", + "MESSAGE": "Updates the MAME XML file", }, }, } diff --git a/backend/main.py b/backend/main.py index ba73be882..e535d6da1 100644 --- a/backend/main.py +++ b/backend/main.py @@ -22,7 +22,7 @@ from config import ( ENABLE_SCHEDULED_UPDATE_MAME_XML, SCHEDULED_UPDATE_MAME_XML_CRON, ) -from endpoints import search, platform, rom, identity, oauth, scan # noqa +from endpoints import search, platform, rom, identity, oauth, scan, tasks # noqa from handler import dbh from utils.socket import socket_app from utils.auth import ( @@ -68,6 +68,7 @@ app.include_router(identity.router) app.include_router(platform.router) app.include_router(rom.router) app.include_router(search.router) +app.include_router(tasks.router) add_pagination(app) app.mount("/ws", socket_app) @@ -81,7 +82,7 @@ def heartbeat(): "WATCHER": { "ENABLED": ENABLE_RESCAN_ON_FILESYSTEM_CHANGE, "TITLE": "Rescan on filesystem change", - "MESSAGE": f"Runs a scan when a change is detected in the library path, with a {RESCAN_ON_FILESYSTEM_CHANGE_DELAY} minutes delay", + "MESSAGE": f"Runs a scan when a change is detected in the library path, with a {RESCAN_ON_FILESYSTEM_CHANGE_DELAY} minute delay", }, "SCHEDULER": { "RESCAN": { @@ -100,7 +101,7 @@ def heartbeat(): "ENABLED": ENABLE_SCHEDULED_UPDATE_MAME_XML, "CRON": SCHEDULED_UPDATE_MAME_XML_CRON, "TITLE": "Scheduled MAME XML update", - "MESSAGE": "Updates the Nintedo MAME XML file", + "MESSAGE": "Updates the MAME XML file", }, }, } diff --git a/backend/tasks/update_mame_xml.py b/backend/tasks/update_mame_xml.py index 23aa78910..e33c399ac 100644 --- a/backend/tasks/update_mame_xml.py +++ b/backend/tasks/update_mame_xml.py @@ -20,7 +20,7 @@ class UpdateMAMEXMLTask(RemoteFilePullTask): description="mame xml update", enabled=ENABLE_SCHEDULED_UPDATE_MAME_XML, cron_string=SCHEDULED_UPDATE_MAME_XML_CRON, - url="https://hyperlist.hyperspin-fe.com/genall.php?system=6", + url="https://gist.githubusercontent.com/gantoine/0e2b9e25962bfd661ad2fe0ba0e72766/raw/59133cc98fa4c58992e4a789db394a85953b24df/gistfile1.txt", file_path=FIXTURE_FILE_PATH, ) diff --git a/backend/utils/oauth.py b/backend/utils/oauth.py index 14cb66b21..90152265d 100644 --- a/backend/utils/oauth.py +++ b/backend/utils/oauth.py @@ -28,6 +28,7 @@ WRITE_SCOPES_MAP: Final = { FULL_SCOPES_MAP: Final = { "users.read": "View users", "users.write": "Modify users", + "tasks.run": "Run tasks", } DEFAULT_SCOPES: Final = list(DEFAULT_SCOPES_MAP.keys()) diff --git a/frontend/src/components/Settings/General/TaskStatus/TaskStatusCard.vue b/frontend/src/components/Settings/General/TaskStatus/TaskStatusCard.vue index 807b6444d..48b477a90 100644 --- a/frontend/src/components/Settings/General/TaskStatus/TaskStatusCard.vue +++ b/frontend/src/components/Settings/General/TaskStatus/TaskStatusCard.vue @@ -1,5 +1,5 @@