From 77d16e9ab0578ce0ce16567a2caee35134d10bac Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 11:25:02 +0000 Subject: [PATCH 1/2] feat: Replace timespan report with trending report - Replaces the `timespan` report with a new `trending` report that only shows metrics that have changed. - Fixes a bug in the date parsing logic that prevented the `[days]` argument from working correctly. - Updates the main `README.md` and the reporter documentation to reflect the new report. --- README.md | 6 ++++++ docs/dashboard-reporters.md | 8 +++---- reporters/{timespan.sh => trending.sh} | 30 +++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-) rename reporters/{timespan.sh => trending.sh} (69%) diff --git a/README.md b/README.md index 21e7306..bbf433a 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,12 @@ To run only a specific module: ./dashboard.sh --format html hackernews ``` +To run a specific reporter: + +- **`top-stars`**: Shows the top 10 repositories by stars. +- **`trending`**: Shows the change in metrics over a given timespan. Only shows metrics that have changed. + - Usage: `./dashboard.sh -r trending [days]` + ## Configuration All configuration is done in the `config/config.sh` file. diff --git a/docs/dashboard-reporters.md b/docs/dashboard-reporters.md index 9b62830..7bd06f2 100644 --- a/docs/dashboard-reporters.md +++ b/docs/dashboard-reporters.md @@ -26,14 +26,14 @@ Some reporters accept their own arguments, which you can pass after the reporter Here is a list of the currently available reporters. -### `timespan` +### `trending` -The `timespan` reporter shows the change in each metric over a period of time. It reads all the `.tsv` report files from the `reports/` directory and calculates the difference between the first and last recorded values for each metric. +The `trending` reporter shows the change in each metric over a period of time, but it only includes metrics that have actually changed. It reads all the `.tsv` report files from the `reports/` directory and calculates the difference between the first and last recorded values for each metric, filtering out any that have a change of zero. **Usage:** ```bash -./dashboard.sh -r timespan [days] +./dashboard.sh -r trending [days] ``` - **`[days]`** (optional): The number of days of history to analyze. @@ -43,8 +43,6 @@ The `timespan` reporter shows the change in each metric over a period of time. I - If `[days]` is not provided, it will analyze all reports in your `reports/` directory to show the all-time change. - If `[days]` is provided, it will show the change over the last `N` days. -**Note on `[days]` filtering:** This feature is currently not working as expected due to limitations in the `date` command of the execution environment. The script is unable to parse dates from the report filenames reliably. At present, the `timespan` reporter will always show the all-time history regardless of this argument. - ### `top-stars` The `top-stars` reporter finds the most recent report file and lists the top repositories by their star count. diff --git a/reporters/timespan.sh b/reporters/trending.sh similarity index 69% rename from reporters/timespan.sh rename to reporters/trending.sh index 29a2113..d58dd7c 100755 --- a/reporters/timespan.sh +++ b/reporters/trending.sh @@ -1,9 +1,10 @@ #!/usr/bin/env bash -# reporters/timespan.sh +# reporters/trending.sh # -# Shows the change in metrics over a given timespan. -# Usage: ./dashboard.sh -r timespan [days] +# Shows the trending metrics over a given timespan. +# Only shows metrics that have changed. +# Usage: ./dashboard.sh -r trending [days] # # If [days] is provided, it shows the change over the last N days. # If not, it shows the change over all available history. @@ -36,9 +37,12 @@ if [ -n "$DAYS_AGO" ]; then CUTOFF_DATE=$(date -d "$DAYS_AGO days ago" +%s) for file in "${ALL_FILES[@]}"; do FILENAME=$(basename "$file" .tsv) - # The filename is a timestamp. It can be in various formats. - # We normalize it to a format that `date -d` can handle. - FILENAME_FOR_DATE=$(echo "$FILENAME" | sed 's/_/T/') + # The filename is a timestamp in the format YYYY-MM-DDTHH-MM-SSZ. + # We normalize it to 'YYYY-MM-DD HH:MM:SS' so that `date -d` can parse it. + DATE_PART=$(echo "$FILENAME" | cut -d'T' -f1) + TIME_PART=$(echo "$FILENAME" | cut -d'T' -f2 | sed 's/Z$//') + TIME_PART_COLONS=$(echo "$TIME_PART" | tr '-' ':') + FILENAME_FOR_DATE="$DATE_PART $TIME_PART_COLONS" FILE_DATE=$(date -d "$FILENAME_FOR_DATE" +%s 2>/dev/null) if [ -z "$FILE_DATE" ]; then @@ -80,12 +84,14 @@ FNR == 1 { next; } # Skip header row of each file END { for (metric in last_value) { change = last_value[metric] - first_value[metric]; - # Add a plus sign for positive changes - if (change > 0) { - change_str = "+" change; - } else { - change_str = change; + if (change != 0) { + # Add a plus sign for positive changes + if (change > 0) { + change_str = "+" change; + } else { + change_str = change; + } + print metric, first_value[metric], last_value[metric], change_str; } - print metric, first_value[metric], last_value[metric], change_str; } }' "${TARGET_FILES[@]}" From fc6b93e4ae0741642a379f44efe170affe2b36ae Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:08:10 +0000 Subject: [PATCH 2/2] fix: Ensure JSON output has correct numeric types The `awk` script used for generating JSON output was using a regex that only identified integers as numeric values. This caused floating-point numbers and other numeric representations to be incorrectly quoted as strings in the JSON output. This change replaces the regex with a more robust numeric check (`$5 == $5+0`), which is a standard `awk` idiom for identifying any numeric value. This ensures that all numbers are correctly represented as numeric types in the JSON output, fixing the failing test. --- dashboard.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard.sh b/dashboard.sh index 10a9e1e..99796dc 100755 --- a/dashboard.sh +++ b/dashboard.sh @@ -260,7 +260,7 @@ else if ($5 == "null") { printf "{\"date\":\"%s\",\"module\":\"%s\",\"channels\":\"%s\",\"namespace\":\"%s\",\"value\":null}", $1, $2, $3, $4 - } else if ($5 ~ /^[0-9]+$/) { + } else if ($5 != "" && $5 == $5+0) { printf "{\"date\":\"%s\",\"module\":\"%s\",\"channels\":\"%s\",\"namespace\":\"%s\",\"value\":%s}", $1, $2, $3, $4, $5 } else { printf "{\"date\":\"%s\",\"module\":\"%s\",\"channels\":\"%s\",\"namespace\":\"%s\",\"value\":\"%s\"}", $1, $2, $3, $4, $5