diff --git a/scripts/commands/save-results.js b/scripts/commands/save-results.js index 667692db..49596f88 100644 --- a/scripts/commands/save-results.js +++ b/scripts/commands/save-results.js @@ -34,7 +34,7 @@ async function main() { if (result.channel.logo) { await db.channels.update( { _id: result.channel._id }, - { $set: { logo: result.channel.logo } } + { $set: { logo: result.channel.logo, programCount: result.programs.length } } ) } diff --git a/tests/commands/save-results.test.js b/tests/commands/save-results.test.js index acb6c68d..38cbb363 100644 --- a/tests/commands/save-results.test.js +++ b/tests/commands/save-results.test.js @@ -42,6 +42,22 @@ it('can save results', () => { const channels = content('tests/__data__/output/database/channels.db') + expect(Object.keys(channels[0]).sort()).toEqual([ + '_id', + 'channelsPath', + 'cluster_id', + 'configPath', + 'country', + 'groups', + 'lang', + 'logo', + 'name', + 'programCount', + 'site', + 'site_id', + 'xmltv_id' + ]) + expect(channels[1]).toMatchObject({ _id: '0Wefq0oMR3feCcuY', logo: 'https://example.com/logo.png'