add stats, versioning
This commit is contained in:
1 parent
dfd2c2f07d
commit
bcf625d2b0
6 files changed
+33
-6
No files matched your search
+16
-4
@@ -1,8 +1,18 @@
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
|
import git
|
||||||
import src.banner as banner
|
import src.banner as banner
|
||||||
|
|
||||||
|
|
||||||
|
def get_git_commit():
|
||||||
|
"""Get first 6 characters of current git commit hash"""
|
||||||
|
try:
|
||||||
|
repo = git.Repo(search_parent_directories=True)
|
||||||
|
return repo.head.commit.hexsha[:6]
|
||||||
|
except Exception:
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
# Server socket
|
# Server socket
|
||||||
bind = "127.0.0.1:7433" # nginx will proxy to this
|
bind = "127.0.0.1:7433" # nginx will proxy to this
|
||||||
backlog = 2048
|
backlog = 2048
|
||||||
@@ -71,11 +81,13 @@ def on_reload(server):
|
|||||||
|
|
||||||
|
|
||||||
def when_ready(server):
|
def when_ready(server):
|
||||||
print(banner.generate("studspider v0.1"))
|
commit_hash = get_git_commit()
|
||||||
|
print(f"{banner.generate("studspider v0.3.0")} - {commit_hash}")
|
||||||
print("Built for PLAY-WELL TEKNOLOGIES by contact@studspider.sh\n\n")
|
print("Built for PLAY-WELL TEKNOLOGIES by contact@studspider.sh\n\n")
|
||||||
print(f"STUDSPIDER HOOK v0.1 RUNNING ON {bind}")
|
print(f"BOOTING ON:\t{bind}")
|
||||||
print(f"WORKERS: {workers}")
|
print(f"WORKERS:\t{workers}")
|
||||||
print(f"WORKING CLASS: {worker_class}\n")
|
print(f"WORKER TYPE:\t{worker_class}")
|
||||||
|
print(f"{'=' * 60}\n")
|
||||||
|
|
||||||
|
|
||||||
def worker_int(worker):
|
def worker_int(worker):
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "studpider"
|
name = "studpider"
|
||||||
version = "0.1.0"
|
version = "0.3.0"
|
||||||
description = ""
|
description = ""
|
||||||
authors = [{ name = "CF", email = "ph0sgene@pm.me" }]
|
authors = [{ name = "CF", email = "ph0sgene@pm.me" }]
|
||||||
requires-python = ">=3.13,<3.14"
|
requires-python = ">=3.13,<3.14"
|
||||||
@@ -22,6 +22,7 @@ dependencies = [
|
|||||||
"uvicorn>=0.40.0",
|
"uvicorn>=0.40.0",
|
||||||
"gunicorn>=23.0.0",
|
"gunicorn>=23.0.0",
|
||||||
"async-lru>=2.0.4",
|
"async-lru>=2.0.4",
|
||||||
|
"gitpython>=3.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="studspider",
|
name="studspider",
|
||||||
version="0.1",
|
version="0.3.0",
|
||||||
description="Bricket + Square integration application",
|
description="Bricket + Square integration application",
|
||||||
author="CF",
|
author="CF",
|
||||||
author_email="chris-forst@pm.me",
|
author_email="chris-forst@pm.me",
|
||||||
|
|||||||
@@ -4,11 +4,22 @@ Queries Square catalog to collect metrics about LEGO inventory quality.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import git
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
from square import AsyncSquare
|
from square import AsyncSquare
|
||||||
from . import get_sq_env
|
from . import get_sq_env
|
||||||
from . import abricksetapi
|
from . import abricksetapi
|
||||||
|
|
||||||
|
|
||||||
|
def get_git_commit() -> str:
|
||||||
|
"""Get first 6 characters of current git commit hash"""
|
||||||
|
try:
|
||||||
|
repo = git.Repo(search_parent_directories=True)
|
||||||
|
return repo.head.commit.hexsha[:6]
|
||||||
|
except Exception:
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
# Initialize Square client
|
# Initialize Square client
|
||||||
client = AsyncSquare(token=get_sq_env.SQUARE_TOKEN, environment=get_sq_env.environment)
|
client = AsyncSquare(token=get_sq_env.SQUARE_TOKEN, environment=get_sq_env.environment)
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ async def get_stats():
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"status": "success",
|
"status": "success",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"git_commit": stats.get_git_commit(),
|
||||||
"stats": daily_stats,
|
"stats": daily_stats,
|
||||||
"completion_rate": round(completion_rate, 1),
|
"completion_rate": round(completion_rate, 1),
|
||||||
"brickset_cache": cache_stats,
|
"brickset_cache": cache_stats,
|
||||||
|
|||||||
Reference in new issue
Block a user