From 8386d62702e1dd0b9914f886f69a83d7ac3f7b5a Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 17 Nov 2021 14:49:10 +0000 Subject: [PATCH] [FIX] website: change the asset disabling from GC to CRON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the behavior disabling the unused snippet assets was put directly in the autovacuum CRON instead of its own CRON. That behavior is leading to some perf-issue running the autovacuum cron since it would take too much time. Indeed, the code will loop inside as many snippet as it exists, and every time then perform an SQL Query to get the HTML fields using the snippet. An improvement will come later to not loop on every snippet anymore. task-2694120 closes odoo/odoo#79981 X-original-commit: 96ab95d37c9b442a4ccb737fd867ca91ec1c11b6 Signed-off-by: Jérémy Kersten (jke) --- addons/website/__manifest__.py | 1 + addons/website/data/ir_cron_data.xml | 12 ++++++++++++ addons/website/models/website.py | 1 - 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 addons/website/data/ir_cron_data.xml diff --git a/addons/website/__manifest__.py b/addons/website/__manifest__.py index edc42c81698..45ab701bf5e 100644 --- a/addons/website/__manifest__.py +++ b/addons/website/__manifest__.py @@ -27,6 +27,7 @@ 'security/website_security.xml', 'security/ir.model.access.csv', 'data/ir_asset.xml', + 'data/ir_cron_data.xml', 'data/mail_mail_data.xml', 'data/website_data.xml', 'data/website_visitor_cron.xml', diff --git a/addons/website/data/ir_cron_data.xml b/addons/website/data/ir_cron_data.xml new file mode 100644 index 00000000000..2561ee94395 --- /dev/null +++ b/addons/website/data/ir_cron_data.xml @@ -0,0 +1,12 @@ + + + + Disable unused snippets assets + + code + model._disable_unused_snippets_assets() + 1 + weeks + -1 + + diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 8eb654e0319..30619addb46 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -1424,7 +1424,6 @@ class Website(models.Model): return True return False - @api.autovacuum def _disable_unused_snippets_assets(self): snippets_assets = self._get_snippets_assets() html_fields = self._get_html_fields()