diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-18 08:22:29 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-18 08:22:29 +0700 |
| commit | 65929f7a9c00639a7b1c360ebc9870b221aa5339 (patch) | |
| tree | 04fe40072cda5622f30192073fae3de93c2f694d /indoteknik_custom/models | |
| parent | 78b151a7e90e84dfa3898b75cf4440c714ba9305 (diff) | |
remove useless code, add last seen products, add compile product in user activity log
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/user_activity_log.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/indoteknik_custom/models/user_activity_log.py b/indoteknik_custom/models/user_activity_log.py index bf1414db..3cf7bd58 100755 --- a/indoteknik_custom/models/user_activity_log.py +++ b/indoteknik_custom/models/user_activity_log.py @@ -14,14 +14,40 @@ class UserActivityLog(models.Model): res_user_id = fields.Many2one("res.users", string="User") email = fields.Char(string="Email") update_product = fields.Boolean(string="Update Product") + product_id = fields.Many2one('product.template', string='Product') + + def compile_product(self): + logs = self.env['user.activity.log'].search([ + ('email', '!=', False), + ('product_id', '=', False), + ('url', 'ilike', 'https://indoteknik.co%/shop/product/%'), + ('url', 'not ilike', 'shopping') + ], limit=1000, order='create_date desc') + for log in logs: + _logger.info(log.url) + strip_index = i = 0 + for c in log.url: + if c == '-': + strip_index = i + i += 1 + product_id = log.url[strip_index + 1:len(log.url)] + if '#' in product_id: + continue + if any(ch.isalpha() for ch in product_id): + continue + product = self.env['product.template'].search([ + ('id', '=', product_id) + ]) + log.product_id = product def clean_activity_log(self): current_time = datetime.now() - delta_time = current_time - timedelta(days=60) + delta_time = current_time - timedelta(days=180) delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') self.env['user.activity.log'].search([ ('create_date', '<', delta_time), + ('email', '=', 'False'), ]).unlink() def reset_rank_search_weekly(self): |
