Skip to content

Commit

Permalink
Hit slightly lighter
Browse files Browse the repository at this point in the history
  • Loading branch information
KenwoodFox committed Jan 16, 2025
1 parent 98bca08 commit 9b4f4da
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

from app.routes.index import index_bp
from app.routes.screens import screens_bp
from app.filters.time_formatter import time_ago

from app.services.github_service import GitHubService


app = Flask(__name__)

# Filters
app.jinja_env.filters["time_ago"] = time_ago


def create_app():
# Register Blueprints
Expand Down
20 changes: 20 additions & 0 deletions app/filters/time_formatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from flask import Flask
from datetime import datetime


def time_ago(dt):
if dt is None:
return "Never updated"

now = datetime.now()
delta = now - dt
seconds = delta.total_seconds()

if seconds < 60:
return f"{int(seconds)} seconds ago"
elif seconds < 3600:
return f"{int(seconds // 60)} minute(s) ago"
elif seconds < 86400:
return f"{int(seconds // 3600)} hour(s) ago"
else:
return f"{int(seconds // 86400)} day ago"
12 changes: 10 additions & 2 deletions app/routes/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ def test_screen():

@screens_bp.route("/pending")
def pending_screen():
return render_template("pending.html", **app.github_service.latest_data)
return render_template(
"pending.html",
**app.github_service.latest_data,
last_updated=app.github_service.last_updated,
)


@screens_bp.route("/table")
def table_screen():
return render_template("table.html", **app.github_service.latest_data)
return render_template(
"table.html",
**app.github_service.latest_data,
last_updated=app.github_service.last_updated,
)
5 changes: 4 additions & 1 deletion app/services/github_service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
import threading
from datetime import datetime

from github import Github

Expand All @@ -21,6 +22,7 @@ def __init__(self, token, repos, username_mapping):
"pull_requests_count": 0,
"pending_reviews": [],
}
self.last_updated = None

def fetch_data(self):
"""Main loop for updating GitHub data."""
Expand All @@ -29,8 +31,9 @@ def fetch_data(self):
self.update_pending_reviews()

print("Updated github data.")
self.last_updated = datetime.now()

time.sleep(90)
time.sleep(120)

def get_mapped_username(self, username):
return self.username_mapping.get(username, username)
Expand Down
22 changes: 22 additions & 0 deletions app/static/styles/pending.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@ body {
border: 2px solid #ffa500;
}

/* ====== */
/* Footer */
/* ====== */
.page-footer {
position: fixed;
bottom: 10px;
left: 10px;
font-size: 0.9em;
color: #aaa;
background: #333;
padding: 5px 10px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
z-index: 1000; /* Ensure it stays above other elements */
font-family: "Courier New", Courier, monospace;
}

.page-footer a {
color: #ffa500; /* Link color */
text-decoration: none;
}

/* Flashing Animation */
@keyframes flash {
from {
Expand Down
22 changes: 22 additions & 0 deletions app/static/styles/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,28 @@ body {
color: #f44336;
}

/* ====== */
/* Footer */
/* ====== */
.page-footer {
position: fixed;
bottom: 10px;
left: 10px;
font-size: 0.9em;
color: #aaa;
background: #333;
padding: 5px 10px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
z-index: 1000; /* Ensure it stays above other elements */
font-family: "Courier New", Courier, monospace;
}

.page-footer a {
color: #ffa500; /* Link color */
text-decoration: none;
}

/* ====== */
/* Labels */
/* ====== */
Expand Down
3 changes: 3 additions & 0 deletions app/templates/pending.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
{% endfor %}
</div>

<div class="page-footer">
<p>Last updated: {{ last_updated | time_ago }}</p>
</div>
</body>

</html>
4 changes: 4 additions & 0 deletions app/templates/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ <h2>Pull Requests ({{ pull_requests_count }})</h2>
</div>
</div>
</section>

<div class="page-footer">
<p>Last updated: {{ last_updated | time_ago }}</p>
</div>
</body>

</html>

0 comments on commit 9b4f4da

Please sign in to comment.