From a78d999a61e1732ae0fe09a52bb10da796bb75b7 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 21 Nov 2025 11:34:51 +0000
Subject: [PATCH] Fix trailing whitespace and finalize performance improvements
Co-authored-by: Nathanwoodburn <62039630+Nathanwoodburn@users.noreply.github.com>
---
cache_helper.py | 46 +++++++++++++++++++++++-----------------------
server.py | 4 ++--
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/cache_helper.py b/cache_helper.py
index b90efd3..cf47cc2 100644
--- a/cache_helper.py
+++ b/cache_helper.py
@@ -18,17 +18,17 @@ def get_nc_config():
"""
Get NC_CONFIG with caching (1 hour TTL).
Falls back to default config on error.
-
+
Returns:
dict: Configuration dictionary
"""
global _nc_config_cache
current_time = datetime.datetime.now().timestamp()
-
+
# Check if cache is valid
if _nc_config_cache["data"] and (current_time - _nc_config_cache["timestamp"]) < _nc_config_ttl:
return _nc_config_cache["data"]
-
+
# Fetch new config
try:
config = requests.get(
@@ -53,17 +53,17 @@ _git_data_ttl = 300 # 5 minutes cache
def get_git_latest_activity():
"""
Get latest git activity with caching (5 minute TTL).
-
+
Returns:
dict: Git activity data or default values
"""
global _git_data_cache
current_time = datetime.datetime.now().timestamp()
-
+
# Check if cache is valid
if _git_data_cache["data"] and (current_time - _git_data_cache["timestamp"]) < _git_data_ttl:
return _git_data_cache["data"]
-
+
# Fetch new data
try:
git = requests.get(
@@ -78,11 +78,11 @@ def get_git_latest_activity():
return result
except Exception as e:
print(f"Error fetching git data: {e}")
-
+
# Return cached or default
if _git_data_cache["data"]:
return _git_data_cache["data"]
-
+
return {
"repo": {
"html_url": "https://nathan.woodburn.au",
@@ -100,20 +100,20 @@ _projects_ttl = 7200 # 2 hours cache
def get_projects(limit=3):
"""
Get projects list with caching (2 hour TTL).
-
+
Args:
limit (int): Number of projects to return
-
+
Returns:
list: List of project dictionaries
"""
global _projects_cache
current_time = datetime.datetime.now().timestamp()
-
+
# Check if cache is valid
if _projects_cache["data"] and (current_time - _projects_cache["timestamp"]) < _projects_ttl:
return _projects_cache["data"][:limit]
-
+
# Fetch new data
try:
projects = []
@@ -122,7 +122,7 @@ def get_projects(limit=3):
timeout=5
)
projects = projectsreq.json()
-
+
# Check for pagination
pageNum = 2
while 'rel="next"' in projectsreq.headers.get("link", ""):
@@ -135,16 +135,16 @@ def get_projects(limit=3):
# Safety limit
if pageNum > 10:
break
-
+
# Process projects
for project in projects:
if project.get("avatar_url") in ("https://git.woodburn.au/", ""):
project["avatar_url"] = "/favicon.png"
project["name"] = project["name"].replace("_", " ").replace("-", " ")
-
+
# Sort by last updated
projects_sorted = sorted(projects, key=lambda x: x.get("updated_at", ""), reverse=True)
-
+
# Remove duplicates by name
seen_names = set()
unique_projects = []
@@ -152,7 +152,7 @@ def get_projects(limit=3):
if project["name"] not in seen_names:
unique_projects.append(project)
seen_names.add(project["name"])
-
+
_projects_cache = {"data": unique_projects, "timestamp": current_time}
return unique_projects[:limit]
except Exception as e:
@@ -170,17 +170,17 @@ _uptime_ttl = 300 # 5 minutes cache
def get_uptime_status():
"""
Get uptime status with caching (5 minute TTL).
-
+
Returns:
bool: True if services are up, False otherwise
"""
global _uptime_cache
current_time = datetime.datetime.now().timestamp()
-
+
# Check if cache is valid
if _uptime_cache["data"] is not None and (current_time - _uptime_cache["timestamp"]) < _uptime_ttl:
return _uptime_cache["data"]
-
+
# Fetch new data
try:
uptime = requests.get(
@@ -204,7 +204,7 @@ def get_uptime_status():
def get_wallet_tokens():
"""
Get wallet tokens with caching.
-
+
Returns:
list: List of token dictionaries
"""
@@ -220,7 +220,7 @@ def get_wallet_tokens():
def get_coin_names():
"""
Get coin names with caching.
-
+
Returns:
dict: Dictionary of coin names
"""
@@ -236,7 +236,7 @@ def get_coin_names():
def get_wallet_domains():
"""
Get wallet domains with caching.
-
+
Returns:
dict: Dictionary of wallet domains
"""
diff --git a/server.py b/server.py
index e502c43..dd35bb5 100644
--- a/server.py
+++ b/server.py
@@ -273,7 +273,7 @@ def index():
custom += ""
else:
custom += ""
-
+
# Special names
if repo_name == "nathanwoodburn.github.io":
repo_name = "Nathan.Woodburn/"
@@ -429,7 +429,7 @@ def donate():
domain = domains[crypto]
cryptoHTML += "
Or send to this domain on compatible wallets:
"
cryptoHTML += f'{domain}'
-
+
if address:
cryptoHTML += (
'
