# -*- coding: utf-8 -*-
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    do_cron_health_enabled = fields.Boolean(
        string='Monitor Cron Health', default=True,
        config_parameter='do_cron_health.enabled',
        help="Record a health log row for every scheduled-action run.")
    do_cron_health_stale_minutes = fields.Integer(
        string='Mark Running Stale After (min)', default=60,
        config_parameter='do_cron_health.stale_minutes',
        help="A run still 'running' after this many minutes is flagged 'stale' "
             "by the watchdog (catches worker crashes and overlaps).")
    do_cron_health_overrun_multiplier = fields.Float(
        string='Overrun Multiplier', default=3.0,
        config_parameter='do_cron_health.overrun_multiplier',
        help="A running job is 'overrunning' once it exceeds this multiple of "
             "its average duration (minimum 60s).")
    do_cron_health_critical_failures = fields.Integer(
        string='Critical After N Failures', default=3,
        config_parameter='do_cron_health.critical_failures',
        help="Health turns Critical once a cron has this many failed/stale runs.")
    do_cron_health_retention_days = fields.Integer(
        string='Keep Cron Logs (days)', default=30,
        config_parameter='do_cron_health.retention_days',
        help="Health log rows older than this are purged by auto-vacuum.")
