Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
198 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
from django.db import transaction | ||
from django.core.management.base import BaseCommand | ||
from optparse import make_option | ||
from zumanji.github import github | ||
from zumanji.models import Project, Revision | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Updates all revisions by hammering GitHub' | ||
|
||
option_list = BaseCommand.option_list + ( | ||
make_option('--project', '-p', dest='projects', help='Limit to project(s)', action='append'), | ||
make_option('--refetch', '-r', dest='refetch', help='Refetch all data from GitHub', action='store_true'), | ||
) | ||
|
||
@transaction.commit_on_success | ||
def handle(self, **options): | ||
for project in Project.objects.filter(label__contains='/'): | ||
def handle(self, projects=None, refetch=False, **options): | ||
if projects: | ||
project_list = list(Project.objects.filter(label__in=projects)) | ||
assert len(projects) == len(projects), 'one or more project label was not found' | ||
else: | ||
project_list = Project.objects.filter(label__contains='/') | ||
|
||
for project in project_list: | ||
print "Project %r" % project.label | ||
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, recurse=False) | ||
if not created and not rev.data: | ||
rev.update_from_github(data, recurse=False) | ||
rev.save() | ||
rev, created = Revision.get_or_create(project, data['sha'], data=data) | ||
if not created: | ||
if not rev.data or refetch: | ||
rev.update_from_github(data) | ||
rev.save() |
116 changes: 116 additions & 0 deletions
116
...migrations/0005_auto__add_revisionparent__add_unique_revisionparent_project_revision_l.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# -*- coding: utf-8 -*- | ||
import datetime | ||
from south.db import db | ||
from south.v2 import SchemaMigration | ||
from django.db import models | ||
|
||
|
||
class Migration(SchemaMigration): | ||
|
||
def forwards(self, orm): | ||
# Adding model 'RevisionParent' | ||
db.create_table('zumanji_revisionparent', ( | ||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||
('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['zumanji.Project'])), | ||
('revision_label', self.gf('django.db.models.fields.CharField')(max_length=64, null=True)), | ||
('parent_label', self.gf('django.db.models.fields.CharField')(max_length=64, null=True)), | ||
)) | ||
db.send_create_signal('zumanji', ['RevisionParent']) | ||
|
||
# Adding unique constraint on 'RevisionParent', fields ['project', 'revision_label', 'parent_label'] | ||
db.create_unique('zumanji_revisionparent', ['project_id', 'revision_label', 'parent_label']) | ||
|
||
# Deleting field 'Revision.parent_label' | ||
db.delete_column('zumanji_revision', 'parent_label') | ||
|
||
# Deleting field 'Revision.parent' | ||
db.delete_column('zumanji_revision', 'parent_id') | ||
|
||
|
||
def backwards(self, orm): | ||
# Removing unique constraint on 'RevisionParent', fields ['project', 'revision_label', 'parent_label'] | ||
db.delete_unique('zumanji_revisionparent', ['project_id', 'revision_label', 'parent_label']) | ||
|
||
# Deleting model 'RevisionParent' | ||
db.delete_table('zumanji_revisionparent') | ||
|
||
# Adding field 'Revision.parent_label' | ||
db.add_column('zumanji_revision', 'parent_label', | ||
self.gf('django.db.models.fields.CharField')(max_length=64, null=True), | ||
keep_default=False) | ||
|
||
# Adding field 'Revision.parent' | ||
db.add_column('zumanji_revision', 'parent', | ||
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['zumanji.Revision'], null=True), | ||
keep_default=False) | ||
|
||
|
||
models = { | ||
'zumanji.build': { | ||
'Meta': {'unique_together': "(('revision', 'datetime'),)", 'object_name': 'Build'}, | ||
'data': ('django.db.models.fields.TextField', [], {'default': '{}', 'blank': 'True'}), | ||
'datetime': ('django.db.models.fields.DateTimeField', [], {}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'num_tests': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), | ||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Project']"}), | ||
'result': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True'}), | ||
'revision': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Revision']"}), | ||
'total_duration': ('django.db.models.fields.FloatField', [], {'default': '0.0'}) | ||
}, | ||
'zumanji.buildtag': { | ||
'Meta': {'object_name': 'BuildTag'}, | ||
'builds': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'tags'", 'symmetrical': 'False', 'to': "orm['zumanji.Build']"}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}) | ||
}, | ||
'zumanji.project': { | ||
'Meta': {'object_name': 'Project'}, | ||
'data': ('django.db.models.fields.TextField', [], {'default': '{}', 'blank': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}) | ||
}, | ||
'zumanji.revision': { | ||
'Meta': {'unique_together': "(('project', 'label'),)", 'object_name': 'Revision'}, | ||
'data': ('django.db.models.fields.TextField', [], {'default': '{}', 'blank': 'True'}), | ||
'datetime': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'label': ('django.db.models.fields.CharField', [], {'max_length': '64'}), | ||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Project']"}) | ||
}, | ||
'zumanji.revisionparent': { | ||
'Meta': {'unique_together': "(('project', 'revision_label', 'parent_label'),)", 'object_name': 'RevisionParent'}, | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'parent_label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}), | ||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Project']"}), | ||
'revision_label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}) | ||
}, | ||
'zumanji.test': { | ||
'Meta': {'unique_together': "(('build', 'label'),)", 'object_name': 'Test'}, | ||
'build': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Build']"}), | ||
'data': ('django.db.models.fields.TextField', [], {'default': '{}', 'blank': 'True'}), | ||
'description': ('django.db.models.fields.TextField', [], {'null': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}), | ||
'lower_duration': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), | ||
'mean_duration': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), | ||
'num_tests': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), | ||
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Test']", 'null': 'True'}), | ||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Project']"}), | ||
'result': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True'}), | ||
'revision': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Revision']"}), | ||
'upper90_duration': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), | ||
'upper_duration': ('django.db.models.fields.FloatField', [], {'default': '0.0'}) | ||
}, | ||
'zumanji.testdata': { | ||
'Meta': {'unique_together': "(('test', 'key'),)", 'object_name': 'TestData'}, | ||
'build': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Build']"}), | ||
'data': ('django.db.models.fields.TextField', [], {'default': '{}', 'blank': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'key': ('django.db.models.fields.CharField', [], {'max_length': '32'}), | ||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Project']"}), | ||
'revision': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Revision']"}), | ||
'test': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['zumanji.Test']"}) | ||
} | ||
} | ||
|
||
complete_apps = ['zumanji'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters