Przeglądaj źródła

refactor: 特殊地级县级暂时过滤,待特殊处理

modood 7 lat temu
rodzic
commit
05f52ab5a3
1 zmienionych plików z 8 dodań i 0 usunięć
  1. 8 0
      lib/worker.js

+ 8 - 0
lib/worker.js

@@ -62,6 +62,8 @@ exports.fetchAreas = async () => {
     const r = await City.paginate({ limit, after })
     for (let i = 0; i < r.results.length; i++) {
       const { dataValues: { code: cityCode, provinceCode } } = r.results[i]
+      // 特殊处理:广东省中山市(3320)、广东省东莞市(4419)、海南省儋州市(4604)没有县级
+      if (['4420', '4419', '4604'].includes(cityCode)) continue
       const o = await crawler.fetchAreas(cityCode)
       for (const code in o) {
         const name = o[code]
@@ -92,9 +94,15 @@ exports.fetchStreets = async () => {
     const r = await Area.paginate({ limit, after })
     for (let i = 0; i < r.results.length; i++) {
       const { dataValues: {
+        name: areaName,
         code: areaCode,
         cityCode,
         provinceCode } } = r.results[i]
+      // 特殊处理:名为市辖区的县级没有乡级
+      // 1. 福建省泉州市金门县(350527)也没有乡级
+      // 2. 甘肃省嘉峪关市下仅一个县级名为市辖区(code: 620201),
+      //    但是它有乡级,因此也需要特殊处理
+      if (areaName === '市辖区' || ['350527'].includes(areaCode)) continue
       const o = await crawler.fetchStreets(areaCode)
       for (const code in o) {
         const name = o[code]