Add country subdivisions codes to the country lists

pull/6702/head
Gabriel Bergeron 3 years ago
parent e1adac57b7
commit 332600501b

@ -35,5 +35,6 @@ api.categories = new API(`${DATA_DIR}/categories.json`)
api.languages = new API(`${DATA_DIR}/languages.json`) api.languages = new API(`${DATA_DIR}/languages.json`)
api.regions = new API(`${DATA_DIR}/regions.json`) api.regions = new API(`${DATA_DIR}/regions.json`)
api.blocklist = new API(`${DATA_DIR}/blocklist.json`) api.blocklist = new API(`${DATA_DIR}/blocklist.json`)
api.subdivisions = new API(`${DATA_DIR}/subdivisions.json`)
module.exports = api module.exports = api

@ -8,12 +8,18 @@ module.exports = async function (streams = []) {
const countries = await api.countries.all() const countries = await api.countries.all()
await api.regions.load() await api.regions.load()
const regions = await api.regions.all() const regions = await api.regions.all()
await api.subdivisions.load()
const subdivisions = await api.subdivisions.all()
const output = [] const output = []
for (const country of countries) { for (const country of countries) {
const countryAreaCodes = _.filter(regions, { countries: [country.code] }).map( let countryRegionCodes = _.filter(regions, { countries: [country.code] }).map(
r => `r/${r.code}` r => `r/${r.code}`
) )
const countrySubdivisionCodes = _.filter(subdivisions, { country: country.code}).map(
r => `s/${r.code}`
)
const countryAreaCodes = countryRegionCodes.concat(countrySubdivisionCodes)
countryAreaCodes.push(`c/${country.code}`) countryAreaCodes.push(`c/${country.code}`)
let items = _.filter(streams, stream => { let items = _.filter(streams, stream => {

Loading…
Cancel
Save