From bfaee558997160c891a394a9862ad338a494337f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 29 Sep 2023 16:54:54 +0700 Subject: delete weekly solr & Helper by di Quotation / SO --- indoteknik_custom/models/solr/apache_solr_queue.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/solr/apache_solr_queue.py') diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 6a5b480f..8dd7c273 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -1,5 +1,5 @@ from odoo import models, fields -from datetime import datetime +from datetime import datetime, timedelta import logging, time @@ -72,3 +72,12 @@ class ApacheSolrQueue(models.Model): if count == 0: self.create(payload) + def delete_weekly_solr(self, limit=500): + solr = self.search([ + ('execute_status', '=', 'success'), + ('execute_date', '>=', (datetime.utcnow() - timedelta(days=7))), + ], limit=limit) + for rec in solr: + rec.unlink() + + -- cgit v1.2.3