Improve add_callback performance.

(imported from commit 4cea356ee6b0777bddfc996d7b8ee1b5fee391c6)
This commit is contained in:
Tim Abbott 2012-09-07 13:51:54 -04:00
parent a53d4e8177
commit 7f6d085ab6
1 changed files with 3 additions and 2 deletions

View File

@ -53,8 +53,9 @@ class UserProfile(models.Model):
def add_callback(self, cb, last_received):
global callback_table
new_zephyrs = filter_by_subscriptions(
Zephyr.objects.filter(id__gt=last_received), self.user)
new_zephyrs = [um.message for um in
UserMessage.objects.filter(user_profile=self,
message__id__gt=last_received)]
if new_zephyrs:
return cb(new_zephyrs)