Author: brosner
Date: Fri Sep 12 10:38:41 2008
New Revision: 47
Modified:
trunk/friendsdev/friends/models.py
Log:
Made use of select_related when building a list of friends in
friends_for_user in FriendshipManager. This makes use of an INNER JOIN to
prevent extra queries on the data set.
Modified: trunk/friendsdev/friends/models.py
==============================================================================
--- trunk/friendsdev/friends/models.py (original)
+++ trunk/friendsdev/friends/models.py Fri Sep 12 10:38:41 2008
@@ -52,9 +52,9 @@
def friends_for_user(self, user):
friends = []
- for friendship in self.filter(from_user=user):
+ for friendship in
self.filter(from_user=user).select_related(depth=1):
friends.append({"friend": friendship.to_user, "friendship":
friendship})
- for friendship in self.filter(to_user=user):
+ for friendship in
self.filter(to_user=user).select_related(depth=1):
friends.append({"friend": friendship.from_user, "friendship":
friendship})
return friends
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---