Controlling the flow of Knowledge

Facts would normally be routed through all of the mutators and finally handed to the output plugins. This is highly restrictive and would force users to write multiple tasks with different filters to handle slight differences in use cases. Let’s not do that.

Tagging facts based on the input plugins that learned them

All plugins accept a configuration option called tags. This option is always an Array of one or more Strings, each one a “tag”.

{   system: {},
    tasks: [{
        name: 'test',
        chain: [{
            plugin: 'youtube',
            plan: '0 0 * * *',
            tags: ['subs'],
            configuration: {
                mode: 'submissions',
                limit: 5
            }
        }, {
            plugin: 'reddit',
            plan: '0 0 * * *',
            tags: ['movies'],
            configuration: {
                subreddit: 'fullmoviesonyoutube',
                mode: 'new',
                limit: 5
            }
        }]
    }]
}

Every fact learned by test/youtube/0 will be tagged with subs, while every fact learned by test/reddit/0 will be tagged movies.

Mutators will interact with all of those facts if the mutator hasn’t been given any tag; or, if the mutator has been tagged, only with facts that share at least one tag with it.

Let’s discard any subs older than 2 days and any movies that don’t have “1080p” in the title:

{   system: {},
    tasks: [{
        name: 'test',
        chain: [{
            plugin: 'youtube',
            plan: '0 */12 * * *',
            tags: ['subs'],
            configuration: {
                mode: 'submissions',
                limit: 5
            }
        }, {
            plugin: 'reddit',
            plan: '0 0 * * *',
            tags: ['movies'],
            configuration: {
                subreddit: 'fullmoviesonyoutube',
                mode: 'new',
                limit: 5
            }
        }, {
            plugin: 'filter',
            tags: ['subs'],
            configuration: {
                'youtube:video:publishedAt': { after: [-2, 'days'] }
            }
        }, {
            plugin: 'filter',
            tags: ['movies'],
            configuration: {
                'reddit:title': { matches: /1080p/i }
            }
        }],
    }]
}

Tagging facts based on their own properties

Using the tagger mutator, it’s possible to virtually split facts into different groups by tagging them differently based on their own characteristics.

More in-depth documentation of this mutator is available in its specific section.

{
    plugin: 'tagger',
    configuration: {
        schemas: [{
            'youtube:video:publishedAt': {after: [-7 days], mandatory: true}
        }, {
            'youtube:video:publishedAt': {before: [-7 days], mandatory: true}
        }],
        schemaTags: [
            'recent',
            'old'
        ]
    }
}