Permalink
Browse files

Denorm the latest commit

  • Loading branch information...
1 parent 6c76fb6 commit 259ff773bba94e0b29987ce15db5b661064d7a86 @paltman paltman committed Sep 10, 2011
@@ -110,5 +110,15 @@ def handle_noargs(self, **options):
month = x["month"],
commit_count = x["count"]
)
+
+ for package in Package.objects.all():
+ try:
+ package.latest_commit = Commit.objects.filter(
+ branch__package=package
+ ).latest("committed_date")
+ package.save()
+ except Commit.DoesNotExist:
+ pass
+
print "Complete."
@@ -82,10 +82,7 @@ class Package(DateAuditModel):
watchers = models.IntegerField(null=True, blank=True)
size = models.IntegerField(null=True, blank=True)
- def last_commit(self):
- return Commit.objects.filter(
- branch__package=self
- ).latest("committed_date")
+ latest_commit = models.ForeignKey("Commit", null=True, blank=True)
def repo(self):
if "://github.com" in self.repo_url:
@@ -0,0 +1 @@
+ALTER TABLE "packages_package" ADD COLUMN "latest_commit_id" integer REFERENCES "packages_commit" ("id") DEFERRABLE INITIALLY DEFERRED;
@@ -15,7 +15,7 @@
</span>
<span class="latest">
- Last Updated on {{ obj.last_commit.committed_date }}
+ Last Updated on {{ obj.latest_commit.committed_date }}
</span>
</h2>

0 comments on commit 259ff77

Please sign in to comment.