-
Notifications
You must be signed in to change notification settings - Fork 2
/
re_extract.py
37 lines (28 loc) · 1.11 KB
/
re_extract.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
from pymongo import MongoClient
from server.controllers.extraction_controller import apply_template
from server.storage import nosql_db as nosqldb
def get_field_bundle_ids_from_ws(db, workspace_id):
field_bundles = db["field_bundle"].find({"workspace_id": workspace_id})
field_bundle_id_list = []
for field_bundle in field_bundles:
if "id" in field_bundle:
field_bundle_id_list.append(field_bundle["id"])
return field_bundle_id_list
def re_run_extraction():
workspace_list = nosqldb.get_all_workspaces()
mongo_str = os.environ["MONGO_HOST"]
db_name = os.environ["MONGO_DATABASE"]
db = MongoClient(mongo_str)[db_name]
for ws in workspace_list:
field_bundle_id_list = get_field_bundle_ids_from_ws(db=db, workspace_id=ws.id)
for field_bundle_id in field_bundle_id_list:
try:
apply_template(
workspace_idx=ws.id,
field_bundle_idx=field_bundle_id,
override_topic="ALL",
)
except Exception:
pass
re_run_extraction()