From 4e4c73faf5077016591f1ad5aeb47a3f901598a8 Mon Sep 17 00:00:00 2001 From: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:38:41 +0200 Subject: [PATCH] fix: correct markdown table parsing for metrics - Use awk -F'|' to parse markdown table columns properly - Extract actual numbers instead of table headers - Should now show '7' instead of '| Total number of items created | 7 |' --- .github/workflows/weekly-metrics-discord.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/weekly-metrics-discord.yml b/.github/workflows/weekly-metrics-discord.yml index 5ff48c8d..cceee0f8 100644 --- a/.github/workflows/weekly-metrics-discord.yml +++ b/.github/workflows/weekly-metrics-discord.yml @@ -49,10 +49,10 @@ jobs: # Parse the metrics from the generated markdown files if [ -f "issue_metrics.md" ]; then # Extract key metrics using grep/awk - AVG_TIME_TO_FIRST_RESPONSE=$(grep -A 1 "Average time to first response" issue_metrics.md | tail -1 | xargs || echo "N/A") - AVG_TIME_TO_CLOSE=$(grep -A 1 "Average time to close" issue_metrics.md | tail -1 | xargs || echo "N/A") - NUM_ISSUES_CREATED=$(grep -A 1 "Total number of items created" issue_metrics.md | tail -1 | xargs || echo "0") - NUM_ISSUES_CLOSED=$(grep -A 1 "Number of items closed" issue_metrics.md | tail -1 | xargs || echo "0") + AVG_TIME_TO_FIRST_RESPONSE=$(grep -A 1 "Average time to first response" issue_metrics.md | tail -1 | awk '{print $3}' || echo "N/A") + AVG_TIME_TO_CLOSE=$(grep -A 1 "Average time to close" issue_metrics.md | tail -1 | awk '{print $3}' || echo "N/A") + NUM_ISSUES_CREATED=$(grep "Total number of items created" issue_metrics.md | awk -F'|' '{print $3}' | xargs || echo "0") + NUM_ISSUES_CLOSED=$(grep "Number of items closed" issue_metrics.md | awk -F'|' '{print $3}' | xargs || echo "0") else NUM_ISSUES_CREATED=0 NUM_ISSUES_CLOSED=0 @@ -61,9 +61,9 @@ jobs: fi if [ -f "pr_metrics.md" ]; then - PR_AVG_TIME_TO_MERGE=$(grep -A 1 "Average time to close" pr_metrics.md | tail -1 | xargs || echo "N/A") - NUM_PRS_CREATED=$(grep -A 1 "Total number of items created" pr_metrics.md | tail -1 | xargs || echo "0") - NUM_PRS_MERGED=$(grep -A 1 "Number of items closed" pr_metrics.md | tail -1 | xargs || echo "0") + PR_AVG_TIME_TO_MERGE=$(grep -A 1 "Average time to close" pr_metrics.md | tail -1 | awk '{print $3}' || echo "N/A") + NUM_PRS_CREATED=$(grep "Total number of items created" pr_metrics.md | awk -F'|' '{print $3}' | xargs || echo "0") + NUM_PRS_MERGED=$(grep "Number of items closed" pr_metrics.md | awk -F'|' '{print $3}' | xargs || echo "0") else NUM_PRS_CREATED=0 NUM_PRS_MERGED=0