Skip to content

Commit

Permalink
fix(china): handle broken location case
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanleo committed Jul 28, 2024
1 parent e3d7ee3 commit ecf226d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/scrapers/china.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,24 @@ export default async function china(): Promise<App.City[]> {
},
});

console.log('Scraped', result.data.airList.length, 'for China');

return Bluebird.map(
result.data.airList,
async (cityDataPoint): Promise<App.City> => {
const location = await getLatLng(
geocoderExceptions[cityDataPoint.CITYNAME] ?? cityDataPoint.CITYNAME
);
let location: App.City['location'] = {
lat: 0,
lng: 0,
};

try {
location = await getLatLng(
geocoderExceptions[cityDataPoint.CITYNAME] ?? cityDataPoint.CITYNAME
);
} catch (e) {
console.error(e);
console.log('Using dummy location for', cityDataPoint.CITYNAME);
}

return {
name: cityDataPoint.CITYNAME,
Expand Down

0 comments on commit ecf226d

Please sign in to comment.