Bläddra i källkod

修复上传MongoDB统计数量错误问题

dongzhaorui 1 år sedan
förälder
incheckning
73088f5876
1 ändrade filer med 7 tillägg och 2 borttagningar
  1. 7 2
      A数据处理/sync_data/summary.py

+ 7 - 2
A数据处理/sync_data/summary.py

@@ -49,7 +49,7 @@ def save(documents, collection, ordered=False):
         data_lst.append(item)
         if len(data_lst) == 100:
             ret = collection.insert_many(data_lst, ordered)
-            logger.info(f"MongoDB {collection.name} 保存 {len(ret)} 条数据")
+            logger.info(f"MongoDB {collection.name} 保存 {len(ret.inserted_ids)} 条数据")
             data_lst = []
 
     if data_lst:
@@ -223,7 +223,12 @@ def zgzb_crawl_aggregate_of_list_pages(datestr=None):
         logger.info("中国招标投标公共服务平台 - 数据汇总完成")
 
 
-if __name__ == '__main__':
+def start_summary():
     feapder_crawl_aggregate_of_list_pages()
     competing_products_crawl_aggregate_of_list_pages()
     zgzb_crawl_aggregate_of_list_pages()
+    logger.info("数据汇总完成")
+
+
+if __name__ == '__main__':
+    start_summary()