From 7f521b01d4366d1c9157a99766d1471d9b370a8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 9 Jun 2014 16:24:25 +0200 Subject: [PATCH 1/1] Quick hack for a better handling of users with many Chunks 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/catalogue/models/listeners.py b/apps/catalogue/models/listeners.py index f98fba4d..f8120a07 100755 --- a/apps/catalogue/models/listeners.py +++ b/apps/catalogue/models/listeners.py @@ -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) -- 2.20.1