소스 검색

新增任务数据管道

dongzhaorui 1 년 전
부모
커밋
0520fbcec5
1개의 변경된 파일24개의 추가작업 그리고 0개의 파일을 삭제
  1. 24 0
      FworkSpider/feapder/pipelines/mongo_pipeline.py

+ 24 - 0
FworkSpider/feapder/pipelines/mongo_pipeline.py

@@ -82,3 +82,27 @@ class MongoPipeline(BasePipeline):
         except Exception as e:
         except Exception as e:
             log.exception(e)
             log.exception(e)
             return False
             return False
+
+
+class TaskPipeline(MongoPipeline):
+
+    def find_items(self, table, condition=None, limit=10):
+        """
+        数据查询
+        @param str table: 表名
+        @param dict condition: 查询条件
+        @param limit: 查询数量
+        @return:
+        """
+        items = self.to_db.find(table, condition, limit)
+        datas = [{'_id': item['_id'], 'state': 1} for item in items]
+        update_keys = ['state']
+        try:
+            self.to_db.add_batch(
+                coll_name=table,
+                datas=datas,
+                update_columns=update_keys,
+            )
+        except Exception as e:
+            log.exception(e)
+        return items