From c82b85e5db7cdd4397431411197bb9baca752b3a Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 21 May 2015 22:14:54 +0100 Subject: [PATCH] Made selecting items in revisions more efficient --- RIGS/rigboard.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 81e7f24f..a24e7be8 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -215,11 +215,10 @@ class EventRevisions(generic.ListView): return zip(key,old,new) def compare_items(self, old, new): - # Need to manually query the version history to get each items events. - # THIS WHOLE METHOD WILL BE SLOW + item_type = ContentType.objects.get_for_model(models.EventItem) - old_items = Version.objects.filter(revision_id=old.revision_id, content_type=item_type) - new_items = Version.objects.filter(revision_id=new.revision_id, content_type=item_type) + old_items = old.revision.version_set.filter(content_type=item_type) + new_items = new.revision.version_set.filter(content_type=item_type) class ItemCompare(object): def __init__(self, old=None, new=None):