mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-22 05:14:22 +00:00
oops actually use the cache
This commit is contained in:
1 file changed
+6
-5
@@ -4369,19 +4369,20 @@ def get_github_stars() -> int | None:
|
|||||||
Fetch the number of stars for the Paperless-NGX repository from GitHub.
|
Fetch the number of stars for the Paperless-NGX repository from GitHub.
|
||||||
"""
|
"""
|
||||||
count = cache.get(GITHUB_CACHE_KEY % "stars")
|
count = cache.get(GITHUB_CACHE_KEY % "stars")
|
||||||
|
if count is not None:
|
||||||
|
return count
|
||||||
try:
|
try:
|
||||||
resp = httpx.get(
|
resp = httpx.get(
|
||||||
"https://api.github.com/repos/paperless-ngx/paperless-ngx",
|
"https://api.github.com/repos/paperless-ngx/paperless-ngx",
|
||||||
headers={"Accept": "application/vnd.github.v3+json"},
|
headers={"Accept": "application/vnd.github+json"},
|
||||||
)
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
data = resp.json()
|
count = resp.json()["stargazers_count"]
|
||||||
count = data.get("stargazers_count")
|
|
||||||
cache.set(GITHUB_CACHE_KEY % "stars", count, 60 * 60)
|
|
||||||
return count
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"An error occurred fetching GitHub stars: {e}")
|
logger.debug(f"An error occurred fetching GitHub stars: {e}")
|
||||||
return None
|
return None
|
||||||
|
cache.set(GITHUB_CACHE_KEY % "stars", count, 60 * 60)
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
@extend_schema_view(
|
@extend_schema_view(
|
||||||
|
|||||||
Reference in new issue
Block a user