From 95a466f1c7b0d469fcb317514a20b3220ed78862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Fri, 26 Feb 2021 15:52:52 +0100 Subject: [PATCH] data: don't build the cache on cell update (#51472) --- combo/data/models.py | 4 ++++ tests/test_manager.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/combo/data/models.py b/combo/data/models.py index 768ac17b..34279aa0 100644 --- a/combo/data/models.py +++ b/combo/data/models.py @@ -2014,4 +2014,8 @@ def cell_maintain_page_cell_cache(sender, instance=None, **kwargs): if not instance.page_id: return page = instance.page + if kwargs.get('created') is False: + # don't build the cache on update, but update page's last_update_timestamp + page.save(update_fields=['last_update_timestamp']) + return page.build_cell_cache() diff --git a/tests/test_manager.py b/tests/test_manager.py index 5319ddea..21983c05 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -832,7 +832,7 @@ def test_site_export_import_json(app, admin_user): resp.form['site_file'] = Upload('site-export.json', site_export, 'application/json') with CaptureQueriesContext(connection) as ctx: resp = resp.form.submit() - assert len(ctx.captured_queries) in [1140, 1141] + assert len(ctx.captured_queries) in [853, 854] Page.objects.all().delete() assert LinkCell.objects.count() == 0 @@ -841,7 +841,7 @@ def test_site_export_import_json(app, admin_user): resp.form['site_file'] = Upload('site-export.json', site_export, 'application/json') with CaptureQueriesContext(connection) as ctx: resp = resp.form.submit() - assert len(ctx.captured_queries) == 665 + assert len(ctx.captured_queries) == 378 assert set(Page.objects.get(slug='one').related_cells['cell_types']) == set( ['data_textcell', 'data_linkcell'] )