Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion osrc/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from math import sqrt

from . import stats
from .stats import get_last_updated

frontend = flask.Blueprint("frontend", __name__)

Expand Down Expand Up @@ -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)

Expand All @@ -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("/<username>/<reponame>.json")
Expand Down
6 changes: 6 additions & 0 deletions osrc/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion osrc/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<a href="http://dan.iel.fm">Dan Foreman-Mackey</a> based on event
data from the <a href="https://github.com">GitHub</a>
<a href="http://githubarchive.org">timeline</a>.
Want <a href="/#how-it-works">more information</a>?
Want <a href="/#how-it-works">more information</a>?<br />
Last updated: {{ last_updated }}
</div>
</div>

Expand Down
3 changes: 3 additions & 0 deletions osrcd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import time
import shutil
import logging
import requests
import datetime
from datetime import date, timedelta
from tempfile import NamedTemporaryFile

Expand Down Expand Up @@ -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
Expand Down