definitions:
    analytics_channel_calculate_rfm:
        label:   'Calculate RFM analytics for Channel'
        enabled: true
        entity:  OroCRM\Bundle\ChannelBundle\Entity\Channel
        order:   30
        actions_configuration:
            - @assign_constant_value:
                attribute: $.dataChannelStatusActive
                value: OroCRM\Bundle\ChannelBundle\Entity\Channel::STATUS_ACTIVE
            - @assign_constant_value:
                attribute: $.commandName
                value: OroCRM\Bundle\AnalyticsBundle\Command\CalculateAnalyticsCommand::COMMAND_NAME
            - @tree:
                conditions:
                    @and:
                        - @equal: [$status, $.dataChannelStatusActive]
                        - @equal: ["$data[rfm_enabled]", true]
                actions:
                    - @format_string:
                        attribute: $.channelArguments
                        string: '--channel=%channel_id%'
                        arguments:
                            channel_id: $id
                    - @create_entity:
                        class: JMS\JobQueueBundle\Entity\Job
                        attribute: $.syncJob
                        flush: true
                        arguments:
                            - $.commandName
                            - [$.channelArguments]

triggers:
    analytics_channel_calculate_rfm:
        -
            event:    update
            priority: 10
            queued:   true
            field:    status
