[FIX] website: change the asset disabling from GC to CRON

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) <jke@openerp.com>
This commit is contained in:
Romain Derie
2021-11-18 08:37:49 +00:00
parent dc8948d79c
commit 8386d62702
3 changed files with 13 additions and 1 deletions
+1
View File
@@ -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',
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="website_disable_unused_snippets_assets" model="ir.cron">
<field name="name">Disable unused snippets assets</field>
<field name="model_id" ref="model_website"/>
<field name="state">code</field>
<field name="code">model._disable_unused_snippets_assets()</field>
<field name="interval_number">1</field>
<field name="interval_type">weeks</field>
<field name="numbercall">-1</field>
</record>
</odoo>
-1
View File
@@ -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()