From 953b7a142d836e486937e4545d481bf33ec98c1a Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 10 Mar 2018 20:14:39 +0100 Subject: [PATCH] [yolo] Keep track of the time diff between public and master commit --- app/models/appci.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/models/appci.py b/app/models/appci.py index e237ff7..ae223fc 100644 --- a/app/models/appci.py +++ b/app/models/appci.py @@ -58,6 +58,11 @@ class AppList(db.Model): known_app.opened_issues = issues_and_prs["nb_issues"] known_app.opened_prs = issues_and_prs["nb_prs"] + known_app.public_vs_master_time_diff = \ + (g.commit_date(known_app, known_app.master_commit) - + g.commit_date(known_app, known_app.public_commit)).days + + db.session.commit() @@ -77,6 +82,7 @@ class App(db.Model): testing_diff = db.Column(db.Integer, default=-1) opened_issues = db.Column(db.Integer, default=-1) opened_prs = db.Column(db.Integer, default=-1) + public_vs_master_time_diff = db.Column(db.Integer, default=9999) def __repr__(self): return '' % self.name @@ -324,3 +330,11 @@ class Github(): repo = app.repo.replace("https://github.com/", "") return self.request('repos/{}/git/refs/heads/{}'.format(repo, ref))["object"]["sha"] + + + def commit_date(self, app, sha): + + repo = app.repo.replace("https://github.com/", "") + github_date = self.request('repos/{}/commits/{}'.format(repo, sha))["commit"]["author"]["date"] + parsed_date = datetime.datetime.strptime(github_date, "%Y-%m-%dT%H:%M:%SZ") + return parsed_date