Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions loop_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -247,6 +262,7 @@
"file_name": f"{file_name.replace('.json', '.html')}#index={index}",
"resolution": "auto",
"browser_version": "chrome",
"status": status,
"thresholds_total": 0,
"thresholds_failed": 0,
"locators": [],
Expand Down
5 changes: 5 additions & 0 deletions post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
3 changes: 2 additions & 1 deletion util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']},"
Expand Down