git.ithinksw.org
/
philo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'shipherd_hotfix'
[philo.git]
/
contrib
/
shipherd
/
models.py
diff --git
a/contrib/shipherd/models.py
b/contrib/shipherd/models.py
index
8efc57a
..
654f5f8
100644
(file)
--- a/
contrib/shipherd/models.py
+++ b/
contrib/shipherd/models.py
@@
-148,18
+148,19
@@
class NavigationManager(models.Manager):
# about that. TODO: Benchmark it.
caches = self.__class__._cache[self.db][node].values()
# about that. TODO: Benchmark it.
caches = self.__class__._cache[self.db][node].values()
- items = []
+ target_pks = set()
for cache in caches:
for cache in caches:
- items += cache['items']
+ target_pks |= set([item.target_node_id for item in cache['items']])
# A distinct query is not strictly necessary. TODO: benchmark the efficiency
# with/without distinct.
# A distinct query is not strictly necessary. TODO: benchmark the efficiency
# with/without distinct.
- targets = list(Node.objects.filter(
shipherd_navigationitem_related__in=item
s).distinct())
+ targets = list(Node.objects.filter(
pk__in=target_pk
s).distinct())
for cache in caches:
for item in cache['items']:
for cache in caches:
for item in cache['items']:
- item.target_node = targets[targets.index(item.target_node)]
+ if item.target_node_id:
+ item.target_node = targets[targets.index(item.target_node)]
def clear_cache(self):
self.__class__._cache.pop(self.db, None)
def clear_cache(self):
self.__class__._cache.pop(self.db, None)