From faaac2e6273b825a8125ba88c7533186261c43cd Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 15 Mar 2022 00:43:06 +0300 Subject: [PATCH] Update regions.js --- scripts/generators/regions.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/generators/regions.js b/scripts/generators/regions.js index 61cc62144f..c238970b22 100644 --- a/scripts/generators/regions.js +++ b/scripts/generators/regions.js @@ -7,9 +7,20 @@ module.exports = async function (streams = []) { await api.regions.load() const regions = await api.regions.all() + await api.subdivisions.load() + const subdivisions = await api.subdivisions.all() + const output = [] for (const region of regions) { - const areaCodes = region.countries.map(code => `c/${code}`) + const regionCountries = region.countries + let areaCodes = regionCountries.map(code => `c/${code}`) + + const regionSubdivisions = _.filter( + subdivisions, + s => regionCountries.indexOf(s.country) > -1 + ).map(s => `s/${s.code}`) + areaCodes = areaCodes.concat(regionSubdivisions) + areaCodes.push(`r/${region.code}`) let items = _.filter(streams, stream => _.intersection(stream.broadcast_area, areaCodes).length)