Projet

Général

Profil

0005-data-don-t-build-the-cache-on-cell-update-51472.patch

Lauréline Guérin, 01 mars 2021 11:22

Télécharger (1,94 ko)

Voir les différences:

Subject: [PATCH 5/7] 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(-)
combo/data/models.py
2014 2014
    if not instance.page_id:
2015 2015
        return
2016 2016
    page = instance.page
2017
    if kwargs.get('created') is False:
2018
        # don't build the cache on update, but update page's last_update_timestamp
2019
        page.save(update_fields=['last_update_timestamp'])
2020
        return
2017 2021
    page.build_cell_cache()
tests/test_manager.py
832 832
    resp.form['site_file'] = Upload('site-export.json', site_export, 'application/json')
833 833
    with CaptureQueriesContext(connection) as ctx:
834 834
        resp = resp.form.submit()
835
        assert len(ctx.captured_queries) in [1140, 1141]
835
        assert len(ctx.captured_queries) in [853, 854]
836 836

  
837 837
    Page.objects.all().delete()
838 838
    assert LinkCell.objects.count() == 0
......
841 841
    resp.form['site_file'] = Upload('site-export.json', site_export, 'application/json')
842 842
    with CaptureQueriesContext(connection) as ctx:
843 843
        resp = resp.form.submit()
844
        assert len(ctx.captured_queries) == 665
844
        assert len(ctx.captured_queries) == 378
845 845
    assert set(Page.objects.get(slug='one').related_cells['cell_types']) == set(
846 846
        ['data_textcell', 'data_linkcell']
847 847
    )
848
-