Spaces:
Running
Running
Update services/report_data_handler.py
Browse files- services/report_data_handler.py +10 -21
services/report_data_handler.py
CHANGED
@@ -15,35 +15,24 @@ logger = logging.getLogger(__name__)
|
|
15 |
|
16 |
def fetch_latest_agentic_analysis(org_urn: str):
|
17 |
"""
|
18 |
-
Fetches
|
19 |
-
Returns the
|
20 |
"""
|
21 |
if not org_urn:
|
22 |
logger.warning("fetch_latest_agentic_analysis: org_urn is missing.")
|
23 |
-
return None
|
24 |
-
|
25 |
-
# Simpler: fetch all from this table (if it's not too large) or filter by org_urn
|
26 |
-
# This example assumes you might fetch more and then filter.
|
27 |
report_data_df, error = fetch_linkedin_posts_data_from_bubble(
|
28 |
data_type=BUBBLE_REPORT_TABLE_NAME,
|
29 |
-
org_urn=org_urn
|
30 |
)
|
31 |
-
|
32 |
if error or report_data_df is None or report_data_df.empty:
|
33 |
logger.info(f"No existing agentic analysis found in Bubble for org_urn {org_urn} or error: {error}")
|
34 |
-
return None
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
if quarter_report_data_df.empty:
|
40 |
-
logger.info(f"No agentic analysis found for org_urn {org_urn} after filtering.")
|
41 |
-
return None
|
42 |
-
|
43 |
-
latest_analysis = quarter_report_data_df.sort_values(by='Created Date', ascending=False).iloc[0]
|
44 |
-
|
45 |
-
logger.info(f"Latest agentic analysis found for org_urn {org_urn}}")
|
46 |
-
return latest_report
|
47 |
|
48 |
|
49 |
def save_agentic_analysis_results(
|
|
|
15 |
|
16 |
def fetch_latest_agentic_analysis(org_urn: str):
|
17 |
"""
|
18 |
+
Fetches all agentic analysis data for a given org_urn from Bubble.
|
19 |
+
Returns the full dataframe and any error, or None, None.
|
20 |
"""
|
21 |
if not org_urn:
|
22 |
logger.warning("fetch_latest_agentic_analysis: org_urn is missing.")
|
23 |
+
return None, None
|
24 |
+
|
|
|
|
|
25 |
report_data_df, error = fetch_linkedin_posts_data_from_bubble(
|
26 |
data_type=BUBBLE_REPORT_TABLE_NAME,
|
27 |
+
org_urn=org_urn
|
28 |
)
|
29 |
+
|
30 |
if error or report_data_df is None or report_data_df.empty:
|
31 |
logger.info(f"No existing agentic analysis found in Bubble for org_urn {org_urn} or error: {error}")
|
32 |
+
return None, None
|
33 |
+
|
34 |
+
logger.info(f"Agentic analysis data fetched for org_urn {org_urn}")
|
35 |
+
return report_data_df, None # Return full dataframe and no error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
def save_agentic_analysis_results(
|