'use strict';

const argv = require('../argv');
const knex = require('../knex');

async function printTitles() {
    const titles = await knex('releases')
        .where((builder) => {
            if (argv.sites) builder.whereIn('sites.slug', argv.sites);
            if (argv.networks) builder.orWhereIn('networks.slug', argv.networks);
        })
        .join('sites', 'sites.id', 'releases.site_id')
        .join('networks', 'networks.id', 'sites.network_id')
        .pluck('title');

    console.log(titles.join('\n'));

    knex.destroy();
}

printTitles();
