From 6faf4f8b7722416ef9039b631bd45da856cfab41 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Wed, 22 Jan 2025 12:17:42 -0500 Subject: [PATCH 1/3] Support new optional variables for fine control --- .gitignore | 1 + README.md | 2 ++ app/routes/index.py | 5 ++++- app/services/github_service.py | 13 +++++++++---- app/static/scripts/autorefresh.js | 7 ++----- app/templates/index.html | 4 ++++ 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 5c334ab..09789e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .db __pycache__ .env +node_modules/ diff --git a/README.md b/README.md index 772cca9..80a673e 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ services: GITHUB_TOKEN: YOUR_TOKEN GITHUB_REPOS: YOUR,REPOS USERNAME_MAP: username:realname, + REFRESH_DURATION: 25 # Optional + API_REFRESH_DURATION: 200 # Optional ``` ## Example setup with openbox autostart diff --git a/app/routes/index.py b/app/routes/index.py index 6f60b33..6b2121b 100644 --- a/app/routes/index.py +++ b/app/routes/index.py @@ -1,3 +1,4 @@ +import os from flask import Blueprint, render_template index_bp = Blueprint("main", __name__) @@ -5,4 +6,6 @@ @index_bp.route("/") def index(): - return render_template("index.html") + return render_template( + "index.html", refresh_duration=int(os.getenv("REFRESH_DURATION", 25)) + ) diff --git a/app/services/github_service.py b/app/services/github_service.py index 7ca8bbe..d56f415 100644 --- a/app/services/github_service.py +++ b/app/services/github_service.py @@ -1,5 +1,7 @@ +import os import time import threading + from datetime import datetime from github import Github @@ -33,7 +35,7 @@ def fetch_data(self): print("Updated github data.") self.last_updated = datetime.now() - time.sleep(120) + time.sleep(int(os.getenv("API_REFRESH_DURATION", 200))) def get_mapped_username(self, username): return self.username_mapping.get(username, username) @@ -54,9 +56,12 @@ def update_general_data(self): "name": milestone.title, "progress": ( ( - milestone.closed_issues - / (milestone.closed_issues + milestone.open_issues) - * 100 + round( + milestone.closed_issues + / (milestone.closed_issues + milestone.open_issues) + * 100, + 2, + ) ) if (milestone.closed_issues + milestone.open_issues) > 0 else 0 diff --git a/app/static/scripts/autorefresh.js b/app/static/scripts/autorefresh.js index a7e9e96..4955009 100644 --- a/app/static/scripts/autorefresh.js +++ b/app/static/scripts/autorefresh.js @@ -1,7 +1,4 @@ document.addEventListener('DOMContentLoaded', () => { - // Configurable refresh duration (in seconds) - const REFRESH_DURATION = 25; - // HTML items const iframe = document.getElementById("board-iframe"); const refreshIndicator = document.getElementById('refresh-indicator'); @@ -9,7 +6,7 @@ document.addEventListener('DOMContentLoaded', () => { let screens = []; let currentScreenIndex = 0; let initialVersion = null; - let countdown = REFRESH_DURATION; + let countdown = REFRESH_DURATION; // Use the dynamic variable async function fetchScreens() { try { @@ -42,7 +39,7 @@ document.addEventListener('DOMContentLoaded', () => { function updateCountdown() { refreshIndicator.innerText = `Changing in ${countdown}s`; if (countdown <= 0) { - countdown = REFRESH_DURATION; + countdown = REFRESH_DURATION; // Reset countdown fetchScreens(); // Fetch screens and check for updates cycleScreens(); // Cycle to the next screen } else { diff --git a/app/templates/index.html b/app/templates/index.html index 7a7eb50..537eabd 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -6,6 +6,10 @@ Project HUD + + From eb031382bb88fb40655bca8885aa1c0ff48b5153 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Wed, 22 Jan 2025 12:21:20 -0500 Subject: [PATCH 2/3] Bump --- app/routes/screens.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/screens.py b/app/routes/screens.py index 3893d3a..fa0b994 100644 --- a/app/routes/screens.py +++ b/app/routes/screens.py @@ -35,7 +35,7 @@ def test_screen(): -

Please Wait! Version {os.getenv('GIT_COMMIT', 'Unknown')}

+

ProjectHUD Starting! Version {os.getenv('GIT_COMMIT', 'Unknown')}

""" From 4a52900224be6961d31510013d0b4547d49bb039 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Wed, 22 Jan 2025 12:22:25 -0500 Subject: [PATCH 3/3] Bump --- .github/workflows/build_docker.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index 8a88275..88283f1 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -1,11 +1,6 @@ name: ProjectHUD CI -on: - push: - branches: - - "*" - tags: - - "*" +on: push env: REGISTRY: ghcr.io