|
@@ -82,3 +82,27 @@ class MongoPipeline(BasePipeline):
|
|
|
except Exception as e:
|
|
|
log.exception(e)
|
|
|
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
|