From 13a278f3b76c9b28ef9fe43742c5f7d99f896fad Mon Sep 17 00:00:00 2001 From: Spoked Date: Wed, 25 Sep 2024 14:05:08 -0400 Subject: [PATCH] fix: remove reverse on event sort --- .gitignore | 1 + poetry.lock | 29 +++++++++++++++++++++-------- pyproject.toml | 1 + src/main.py | 9 +++++++++ src/utils/event_manager.py | 2 +- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 81212c31..47a88894 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ bin/ *.bin .secrets* event.json +*.patch # Python bytecode / Byte-compiled / optimized / DLL files __pycache__/ diff --git a/poetry.lock b/poetry.lock index b05ee320..b11c909a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1863,21 +1863,23 @@ dev = ["importlib-metadata", "tox"] [[package]] name = "pyright" -version = "1.1.381" +version = "1.1.382.post0" description = "Command line wrapper for pyright" optional = false python-versions = ">=3.7" files = [ - {file = "pyright-1.1.381-py3-none-any.whl", hash = "sha256:5dc0aa80a265675d36abab59c674ae01dbe476714f91845b61b841d34aa99081"}, - {file = "pyright-1.1.381.tar.gz", hash = "sha256:314cf0c1351c189524fb10c7ac20688ecd470e8cc505c394d642c9c80bf7c3a5"}, + {file = "pyright-1.1.382.post0-py3-none-any.whl", hash = "sha256:a82a20b6a6511d71c6c95de19c0f874f7e50a013f332e3799deaae66a4d237d1"}, + {file = "pyright-1.1.382.post0.tar.gz", hash = "sha256:4b84dd4439b0cbc662dff6aaf012cc0860f1c788932ac4c2a4b5d6c1280a5e20"}, ] [package.dependencies] nodeenv = ">=1.6.0" +typing-extensions = ">=4.1" [package.extras] -all = ["twine (>=3.4.1)"] +all = ["nodejs-wheel-binaries", "twine (>=3.4.1)"] dev = ["twine (>=3.4.1)"] +nodejs = ["nodejs-wheel-binaries"] [[package]] name = "pysubs2" @@ -2490,6 +2492,17 @@ files = [ {file = "ruff-0.3.7.tar.gz", hash = "sha256:d5c1aebee5162c2226784800ae031f660c350e7a3402c4d1f8ea4e97e232e3ba"}, ] +[[package]] +name = "scalar-fastapi" +version = "1.0.3" +description = "This plugin provides an easy way to render a beautiful API reference based on a OpenAPI/Swagger file with FastAPI." +optional = false +python-versions = "*" +files = [ + {file = "scalar_fastapi-1.0.3-py3-none-any.whl", hash = "sha256:4a47a140795097ad034518ce0e32940f2c54f0f4bc60e4c3289ca30a7e6f954d"}, + {file = "scalar_fastapi-1.0.3.tar.gz", hash = "sha256:9e9cb8398e298cd435a0171eebe1675b8899eb21e47c238db0d48783143f0ffb"}, +] + [[package]] name = "six" version = "1.16.0" @@ -2753,13 +2766,13 @@ weaviate = ["weaviate-client (>=4.5.4,<5.0.0)"] [[package]] name = "textual" -version = "0.80.0" +version = "0.81.0" description = "Modern Text User Interface framework" optional = false python-versions = "<4.0.0,>=3.8.1" files = [ - {file = "textual-0.80.0-py3-none-any.whl", hash = "sha256:d8206530dbcc37fafa153efa43ba91f08182c1623766cbf7bcf504ffa414f608"}, - {file = "textual-0.80.0.tar.gz", hash = "sha256:dbe5d6d759596652cbb4fc29257064e23a175ec1040c34e5847998694a8d57da"}, + {file = "textual-0.81.0-py3-none-any.whl", hash = "sha256:5f94e3bf185a1693c31f5e2bcbc413c8ed093a53abc96a956c65322d48f9543c"}, + {file = "textual-0.81.0.tar.gz", hash = "sha256:b438f7e6bb143fdec379170ccc6709a32d273bd998e70179537109263de7c818"}, ] [package.dependencies] @@ -3248,4 +3261,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "2c32be6a98e1b1572e6cb4a815c1812aada3aec1d33646dffa75e31efedc4342" +content-hash = "42f7ca2f6421e5c1b7e3d6727f6e595eefb0efc9f167072d793ec72d3dfb8c97" diff --git a/pyproject.toml b/pyproject.toml index 78f1ca8e..5a0c8d59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ apprise = "^1.8.1" subliminal = "^2.2.1" rank-torrent-name = "^1.0.2" jsonschema = "^4.23.0" +scalar-fastapi = "^1.0.3" [tool.poetry.group.dev.dependencies] pyright = "^1.1.352" diff --git a/src/main.py b/src/main.py index 84d9f8f7..ea321b96 100644 --- a/src/main.py +++ b/src/main.py @@ -18,6 +18,7 @@ from controllers.tmdb import router as tmdb_router from controllers.webhooks import router as webhooks_router from controllers.ws import router as ws_router +from scalar_fastapi import get_scalar_api_reference from program import Program from program.settings.models import get_version from utils.cli import handle_args @@ -52,6 +53,14 @@ async def dispatch(self, request: Request, call_next): "url": "https://www.gnu.org/licenses/gpl-3.0.en.html", }, ) + +@app.get("/scalar", include_in_schema=False) +async def scalar_html(): + return get_scalar_api_reference( + openapi_url=app.openapi_url, + title=app.title, + ) + app.program = Program() app.add_middleware(LoguruMiddleware) diff --git a/src/utils/event_manager.py b/src/utils/event_manager.py index efd4767b..17e175b2 100644 --- a/src/utils/event_manager.py +++ b/src/utils/event_manager.py @@ -220,7 +220,7 @@ def next(self): while True: if self._queued_events: with self.mutex: - self._queued_events.sort(key=lambda event: event.run_at, reverse=True) + self._queued_events.sort(key=lambda event: event.run_at) if datetime.now() >= self._queued_events[0].run_at: event = self._queued_events.pop(0) return event