update
This commit is contained in:
22
fusion_clock_ai/models/ai_cache.py
Normal file
22
fusion_clock_ai/models/ai_cache.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class FusionClockAICache(models.Model):
|
||||
_name = 'fusion.clock.ai.cache'
|
||||
_description = 'AI Response Cache'
|
||||
_order = 'created_at desc'
|
||||
|
||||
cache_key = fields.Char(required=True, index=True)
|
||||
prompt_key = fields.Char(index=True)
|
||||
response_text = fields.Text(required=True)
|
||||
created_at = fields.Datetime(default=fields.Datetime.now, required=True)
|
||||
|
||||
def _gc_expired_cache(self):
|
||||
"""Cron: delete cache entries older than 24 hours."""
|
||||
cutoff = datetime.now() - timedelta(hours=24)
|
||||
self.search([('created_at', '<', cutoff)]).unlink()
|
||||
Reference in New Issue
Block a user