Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Dont use stats and files information as its more expensive to poll

  • Loading branch information...
commit a5d112094c0e1b5046d0367b49fa6405bf195524 1 parent 02e4880
@dcramer dcramer authored
View
10 src/zumanji/management/commands/poll_github.py
@@ -11,10 +11,10 @@ class Command(BaseCommand):
def handle(self, **options):
for project in Project.objects.filter(label__contains='/'):
print "Project %r" % project.label
- for commit in github.iter_commits(project.github_user, project.github_repo):
- print " Revision %r (%s; %s)" % (commit['sha'], commit['commit']['author']['name'],
- commit['commit']['committer']['date'])
- rev, created = Revision.get_or_create(project, commit['sha'])
+ for data in github.iter_commits(project.github_user, project.github_repo):
+ print " Revision %r (%s; %s)" % (data['sha'], data['commit']['author']['name'],
+ data['commit']['committer']['date'])
+ rev, created = Revision.get_or_create(project, data['sha'], data=data)
if not created and not rev.data:
- rev.update_from_github()
+ rev.update_from_github(data)
rev.save()
View
18 src/zumanji/models.py
@@ -84,14 +84,17 @@ def __unicode__(self):
@classmethod
def sanitize_github_data(cls, data):
- return {
+ result = {
'commit': data['commit'],
- 'stats': data['stats'],
- 'files': [{'filename': f['filename']} for f in data['files']],
}
+ if 'stats' in data:
+ result['stats'] = data['stats']
+ if 'files' in data:
+ result['files'] = [{'filename': f['filename']} for f in data['files']]
+ return result
@classmethod
- def get_or_create(cls, project, label):
+ def get_or_create(cls, project, label, data=None):
"""
Get a revision, and if it doesnt exist, attempt to pull it from Git.
"""
@@ -100,7 +103,7 @@ def get_or_create(cls, project, label):
created = False
except Revision.DoesNotExist:
rev = cls(project=project, label=label)
- rev.update_from_github()
+ rev.update_from_github(data=data)
rev.save()
created = True
@@ -128,8 +131,9 @@ def author(self):
return {}
return self.data['commit']['author']
- def update_from_github(self):
- data = github.get_commit(self.project.github_user, self.project.github_repo, self.label)
+ def update_from_github(self, data=None):
+ if data is None:
+ data = github.get_commit(self.project.github_user, self.project.github_repo, self.label)
datetime = dateutil.parser.parse(data['commit']['committer']['date'])
# LOL MULTIPLE PARENTS HOW DOES GIT WORK
View
4 src/zumanji/templates/zumanji/includes/build_details.html
@@ -31,8 +31,8 @@
<dd>{{ build.revision.label }}{% if build.revision.data %} [<a href="{{ build.revision.details_url }}">git</a>]{% endif %}</dd>
<dt>Author</dt>
<dd>{{ build.revision.data.commit.author.name }} ({{ build.revision.data.commit.author.email }})</dd>
- <dt>Changes</dt>
- <dd>+{{ build.revision.data.stats.additions }} / -{{ build.revision.data.stats.deletions }} ({{ build.revision.data.files|length }} file{% if build.revision.data.files|length != 1 %}s{% endif %})</dd>
+ {# <dt>Changes</dt>
+ <dd>+{{ build.revision.data.stats.additions }} / -{{ build.revision.data.stats.deletions }} ({{ build.revision.data.files|length }} file{% if build.revision.data.files|length != 1 %}s{% endif %})</dd> #}
<dt>Datetime</dt>
<dd>{{ build.revision.data.commit.author.date|date_from_iso }}</dd>
<dt>Message</dt>
Please sign in to comment.
Something went wrong with that request. Please try again.