Quick hack for a better handling of users with many Chunks
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 9 Jun 2014 14:24:25 +0000 (16:24 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 9 Jun 2014 14:24:25 +0000 (16:24 +0200)
This tries to make sure we don't touch every Book and Chunk belonging
to a user just because he or she logged in, which in some cases can be
quite expensive.

apps/catalogue/models/listeners.py

index f98fba4..f8120a0 100755 (executable)
@@ -30,6 +30,9 @@ models.signals.post_save.connect(image_changed, sender=Image)
 
 
 def user_changed(sender, instance, *args, **kwargs):
+    if 'last_login' in kwargs.get('update_fields', []):
+        # Quick hack - this change seems to result from logging user in so just ignore it.
+        return
     books = set()
     for c in instance.chunk_set.all():
         books.add(c.book)