From 1be80b24c2cf4426658a43386b914bbe7eaf672d Mon Sep 17 00:00:00 2001 From: lamusmaser <1940060+lamusmaser@users.noreply.github.com> Date: Tue, 27 Jun 2023 21:50:28 -0600 Subject: [PATCH] Implement #490 - Add version API and add local_version function. (#491) * Add version API and add local_version function. * Minor adjustments for linting. * Add missing newlines for linter. * Add missing comma to `urls.py`. * Remove `version/` endpoint. * Remove the `VersionView`. * Prepare `PingView` for removal of the `is_static` response. * Remove the `is_unstable` response from `ReleaseVersion`. * Readd missing class instantiation for first call of `ReleaseVersion`. --- tubearchivist/api/views.py | 8 ++++++-- tubearchivist/home/src/ta/config.py | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index 15fde1d6..357bd507 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -11,7 +11,7 @@ from home.src.index.channel import YoutubeChannel from home.src.index.generic import Pagination from home.src.index.reindex import ReindexProgress from home.src.index.video import SponsorBlock, YoutubeVideo -from home.src.ta.config import AppConfig +from home.src.ta.config import AppConfig, ReleaseVersion from home.src.ta.ta_redis import RedisArchivist from home.src.ta.task_manager import TaskCommand, TaskManager from home.src.ta.urlparser import Parser @@ -535,7 +535,11 @@ class PingView(ApiBaseView): @staticmethod def get(request): """get pong""" - data = {"response": "pong", "user": request.user.id} + data = { + "response": "pong", + "user": request.user.id, + "version": ReleaseVersion().get_local_version(), + } return Response(data) diff --git a/tubearchivist/home/src/ta/config.py b/tubearchivist/home/src/ta/config.py index f9b34742..671602cb 100644 --- a/tubearchivist/home/src/ta/config.py +++ b/tubearchivist/home/src/ta/config.py @@ -326,6 +326,10 @@ class ReleaseVersion: RedisArchivist().set_message(self.NEW_KEY, message) print(f"[{self.local_version}]: found new version {new_version}") + def get_local_version(self): + """read version from local""" + return self.local_version + def get_remote_version(self): """read version from remote""" self.response = requests.get(self.REMOTE_URL, timeout=20).json()