summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-11-23 11:54:43 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-11-23 11:54:43 +0700
commit59d2d758d4866c5f6a844e885dd49cbee4a2e7c2 (patch)
tree25b6c4cc35cbe5407c456eb8238201b3fe120ec9
parentb94299b803dc2fe229f0f7e1a1569ea1a5d9b648 (diff)
delte user activity log above 3 months
-rwxr-xr-xindoteknik_custom/models/user_activity_log.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/indoteknik_custom/models/user_activity_log.py b/indoteknik_custom/models/user_activity_log.py
index c94e6309..bf1414db 100755
--- a/indoteknik_custom/models/user_activity_log.py
+++ b/indoteknik_custom/models/user_activity_log.py
@@ -16,8 +16,12 @@ class UserActivityLog(models.Model):
update_product = fields.Boolean(string="Update Product")
def clean_activity_log(self):
+ current_time = datetime.now()
+ delta_time = current_time - timedelta(days=60)
+
+ delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
self.env['user.activity.log'].search([
- ('email', 'not ilike', '%@%'),
+ ('create_date', '<', delta_time),
]).unlink()
def reset_rank_search_weekly(self):
@@ -38,7 +42,7 @@ class UserActivityLog(models.Model):
delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
activity_logs = self.env['user.activity.log'].search([
- ('url', 'ilike', '%indoteknik.co%/shop/product/%'),
+ ('url', 'ilike', 'https://indoteknik.co%/shop/product/%'),
('create_date', '>', delta_time),
], limit=4000)
for activity_log in activity_logs: