<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="feed">
        <job name="feed_process_generation_queue" instance="Mirasvit\Feed\Cron\ProcessGenerationQueueCron" method="execute">
            <schedule>* * * * *</schedule>
        </job>
        <!-- Every minute so a feed scheduled by cron expression is honoured within the minute it matches.
             The group's process starts every minute for the jobs around it anyway, and a wake that finds
             nothing due writes nothing. -->
        <job name="feed_export" instance="Mirasvit\Feed\Cron\ExportCron" method="execute">
            <schedule>* * * * *</schedule>
        </job>
        <job name="feed_statistics" instance="Mirasvit\Feed\Cron\FeedStatisticsCron" method="execute">
            <schedule>15,45 * * * *</schedule>
        </job>
        <!-- AI optimization drip: one portion per enabled profile per launch, so a large catalog converges
             over many launches instead of one long job. What bounds a launch is the portion itself — the 30s
             per-profile slice in OptimizationService::PROFILE_TIME_LIMIT — not this interval, which a launch
             can use most of. A launch that overruns costs the next tick rather than doubling up: the cron
             job lock and the runner's own lock both make an overlapping launch a clean no-op. The generation
             queue shares this group's process, so an export never waits on a model. -->
        <job name="feed_process_ai_optimization" instance="Mirasvit\Feed\Cron\ProcessAiOptimizationCron" method="execute">
            <schedule>* * * * *</schedule>
        </job>
    </group>
    <group id="default">
        <!-- Nightly housekeeping on the module's own tables: the mst_feed_feed_product rows left behind
             by a deleted product, which no longer cascade away (see db_schema.xml), and generation
             history older than three days. This replaces the separate feed_history_clean job and keeps its
             slot, so there is one place to read what gets cleaned and when. Daily and in the default
             group on purpose: it is gardening, not part of generating a feed, and it must never compete
             with the feed group's export for that group's single process. -->
        <job name="feed_cleanup" instance="Mirasvit\Feed\Cron\CleanupCron" method="execute">
            <schedule>5 1 * * *</schedule>
        </job>
    </group>
</config>
