-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_investigation.py
More file actions
87 lines (71 loc) · 2.59 KB
/
Copy pathrun_investigation.py
File metadata and controls
87 lines (71 loc) · 2.59 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##################
# run_investigation.py
# The scope of this file is to run end the end-to-end investigation process.
# It will start an investigation, run data acquisition, run products processing, and run reviews processing.
import logging
logging.basicConfig(level=logging.INFO)
from firebase_utils import start_investigation, update_investigation_status
from data_acquisition import execute_data_acquisition
from reviews_processing import run_reviews_investigation
# utils.py or within your main Flask app module
import asyncio
def ensure_event_loop():
try:
if not asyncio.get_event_loop().is_running():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
except RuntimeError as e:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
# %%
def run_end_to_end_investigation(data):
try:
investigationData = start_investigation(data)
if not investigationData:
print("Failed to start the investigation.")
return False
print('Investigation started successfully')
except Exception as e:
print(f"Error starting the investigation: {e}")
return False
asinList = investigationData.get('asinList')
userId = investigationData.get('userId')
investigationId = investigationData.get('id')
if not asinList:
print("No ASINs found for the investigation.")
return False
""" try:
has_investigations_available(userId, db)
except Exception as e:
print(f"Error checking user {userId} for available investigations: {e}")
return False
"""
try:
execute_data_acquisition(asinList)
print('Data acquisition completed successfully')
except Exception as e:
print(f"Error during data acquisition: {e}")
return False
try:
run_reviews_investigation(userId, investigationId)
print('Reviews processing completed successfully')
except Exception as e:
print(f"Error during reviews processing: {e}")
return False
try:
update_investigation_status(userId, investigationId, "finished")
print('Investigation completed successfully')
except Exception as e:
print(f"Error during updating investigation status: {e}")
return False
"""
try:
use_investigation(userId, db)
print(f'Used Investigation from user: {userId}')
except Exception as e:
print(f"Error during using for user: {userId} ,investigation: {e}")
return False
return True
"""
#%%
# ====================