mirror of
https://github.com/tubearchivist/tubearchivist-server.git
synced 2024-11-24 12:40:13 +00:00
call INCR on version check request
This commit is contained in:
parent
35a90941ff
commit
7d48b7f78f
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user