diff --git a/osrc/frontend.py b/osrc/frontend.py index 81498df..00076ef 100644 --- a/osrc/frontend.py +++ b/osrc/frontend.py @@ -8,6 +8,7 @@ from math import sqrt from . import stats +from .stats import get_last_updated frontend = flask.Blueprint("frontend", __name__) @@ -97,6 +98,7 @@ def user_view(username): event_verbs=event_verbs, week_type=week_type, best_time=best_time, + last_updated=get_last_updated(), enumerate=enumerate, **stats) @@ -115,7 +117,7 @@ def repo_view(username, reponame): s = stats.get_repo_info(username, reponame) if s is None: return flask.render_template("noinfo.html") - return flask.render_template("repo.html", **s) + return flask.render_template("repo.html", last_updated=get_last_updated(), **s) @frontend.route("//.json") diff --git a/osrc/stats.py b/osrc/stats.py index ead9626..c81b034 100644 --- a/osrc/stats.py +++ b/osrc/stats.py @@ -18,6 +18,12 @@ ghapi_url = "https://api.github.com/users/{username}" +def get_last_updated(): + pipe = get_pipeline() + pipe.get(format_key("updated")) + + return pipe.execute()[0] + def get_user_info(username): # Normalize the username. user = username.lower() diff --git a/osrc/templates/base.html b/osrc/templates/base.html index 7eb62dc..4a5770f 100644 --- a/osrc/templates/base.html +++ b/osrc/templates/base.html @@ -24,7 +24,8 @@ Dan Foreman-Mackey based on event data from the GitHub timeline. - Want more information? + Want more information?
+ Last updated: {{ last_updated }} diff --git a/osrcd b/osrcd index e334875..145ccd3 100755 --- a/osrcd +++ b/osrcd @@ -19,6 +19,7 @@ import time import shutil import logging import requests +import datetime from datetime import date, timedelta from tempfile import NamedTemporaryFile @@ -97,6 +98,8 @@ def process(filename): # Set up a redis pipeline. pipe = get_pipeline() + pipe.set(_format("updated"), datetime.datetime(year, month, day, hour).strftime("%Y-%m-%d %H:%M:%S")) + # Unzip and load the file. strt = time.time() count = 0