diff --git a/loop_processing.py b/loop_processing.py index e7ac590..d119f0c 100644 --- a/loop_processing.py +++ b/loop_processing.py @@ -227,6 +227,21 @@ logger.debug("INSIDE ACTION TYPE") logger.debug(step["name"]) all_results[metric].append(result.get(metric, 0)) + + # Check next step for status (SUCCESS/FAILED) + status = "undefined" + if index + 1 < len(json_data["steps"]): + next_step = json_data["steps"][index + 1] + if "lhr" in next_step and "gatherMode" in next_step["lhr"]: + if next_step["lhr"]["gatherMode"] == "snapshot": + next_name = next_step.get("name", "") + next_name_upper = next_name.upper() + if next_name_upper.endswith("_SUCCESS"): + status = "SUCCESS" + logger.info(f"Status detected: SUCCESS for {step['name']}") + elif next_name_upper.endswith("_FAILED"): + status = "FAILED" + logger.info(f"Status detected: FAILED for {step['name']}") if 'requestedUrl' in step["lhr"]: logger.debug("STEP requestedUrl") @@ -247,6 +262,7 @@ "file_name": f"{file_name.replace('.json', '.html')}#index={index}", "resolution": "auto", "browser_version": browser_version, + "status": status, "thresholds_total": 0, "thresholds_failed": 0, "locators": [], diff --git a/post_processing.py b/post_processing.py index 8a54f48..8ea3726 100644 --- a/post_processing.py +++ b/post_processing.py @@ -160,6 +160,11 @@ summary_results = {} for each in results: + # Skip rows with FAILED status + if each.get("status") == "FAILED": + logger.info(f"Skipping FAILED row: {each.get('identifier', 'unknown')}") + continue + if each["identifier"] not in summary_results.keys(): summary_results[each["identifier"]] = {"load_time": [], "dom_processing": [], "time_to_interactive": [], "first_contentful_paint": [], "largest_contentful_paint": [], diff --git a/util.py b/util.py index 4cdf6e9..253fa3e 100644 --- a/util.py +++ b/util.py @@ -60,13 +60,14 @@ def upload_file(file_name, file_path, galloper_url, project_id, token, s3_config def update_summary_file(report_id, records, browser_version="not_set"): file_exists = os.path.exists(f"/tmp/{report_id}.csv") - header = "timestamp,name,identifier,type,loop,load_time,dom,tti,fcp,lcp,cls,tbt,fvc,lvc,inp,ttfb,file_name,browser_version\n".encode('utf-8') + header = "timestamp,name,identifier,type,loop,status,load_time,dom,tti,fcp,lcp,cls,tbt,fvc,lvc,inp,ttfb,file_name,browser_version\n".encode('utf-8') with open(f"/tmp/{report_id}.csv", 'ab+') as f: if not file_exists: f.write(header) for each in records: f.write( f"{each['metrics']['timestamps']},{each['name']},{each['identifier']},{each['type']},{each['loop']}," + f"{each.get('status', 'undefined')}," f"{each['metrics']['load_time']},{each['metrics']['dom_processing']}," f"{each['metrics']['time_to_interactive']},{each['metrics']['first_contentful_paint']}," f"{each['metrics']['largest_contentful_paint']},"