diff --git a/tubearchivist/web/src/ta_redis.py b/tubearchivist/web/src/ta_redis.py index 06ae12b..6c16840 100644 --- a/tubearchivist/web/src/ta_redis.py +++ b/tubearchivist/web/src/ta_redis.py @@ -86,3 +86,16 @@ class TaskHandler(RedisBase): def set_pub(self): """set message to pub""" self.conn.publish(self.key, self.repo_conf.get("gh_repo")) + + +class VersionCheckCounter(RedisBase): + """count requests to version check API endpoint""" + + def __init__(self): + super().__init__() + self.timestamp = datetime.now().strftime("%Y%m%d") + self.key = f"{self.NAME_SPACE}versioncounter:{self.timestamp}" + + def increase(self): + """increase counter by one""" + self.conn.execute_command("INCR", self.key) diff --git a/tubearchivist/web/views.py b/tubearchivist/web/views.py index 81c2075..98d36c9 100644 --- a/tubearchivist/web/views.py +++ b/tubearchivist/web/views.py @@ -5,6 +5,7 @@ from os import environ from apscheduler.schedulers.background import BackgroundScheduler from flask import Flask, render_template, jsonify, request, redirect from src.api_docker import run_docker_backup +from src.ta_redis import VersionCheckCounter from src.webhook_docker import DockerHook from src.webhook_github import GithubBackup, GithubHook import markdown @@ -44,6 +45,7 @@ def discord_redirect(): def release(release_id): """api release""" result = GithubBackup(release_id).get_tag() + VersionCheckCounter().increase() return jsonify(result)