|
1 | 1 | #!/bin/bash -e |
2 | 2 |
|
3 | 3 | # Results live under <system>/results/YYYYMMDD/<basename>.json. |
4 | | -# For the website we use only the latest date subdirectory of each |
5 | | -# system's results/, and include every file in that subdirectory. |
6 | | -# Older subdirectories are kept on disk as history but not displayed. |
7 | | -# Entries tagged "historical" are also filtered out. |
| 4 | +# For the website we keep only the latest dated copy per (system, basename), |
| 5 | +# and we skip entries tagged "historical" — those are kept in the repo |
| 6 | +# as archival data but are not displayed on the dashboard. |
8 | 7 |
|
9 | 8 | echo "const data = [" > data.generated.js.new |
10 | 9 | FIRST=1 |
11 | 10 |
|
12 | | -for dir in */; do |
13 | | - dir="${dir%/}" |
14 | | - case "$dir" in |
15 | | - hardware|versions|gravitons) continue;; |
16 | | - esac |
17 | | - [ -d "$dir/results" ] || continue |
18 | | - latest=$(LANG=C ls -1 "$dir/results" 2>/dev/null | sort | tail -1) |
19 | | - [ -n "$latest" ] || continue |
20 | | - [ -d "$dir/results/$latest" ] || continue |
21 | | - |
22 | | - for file in "$dir/results/$latest"/*.json; do |
23 | | - [ -f "$file" ] || continue |
24 | | - if ! entry=$(jq --compact-output --arg src "$file" \ |
25 | | - 'select((.tags // []) | index("historical") | not) | . + {"source": $src}' \ |
26 | | - "$file"); then |
27 | | - echo "Error in $file — skipping" >&2 |
28 | | - continue |
29 | | - fi |
30 | | - [ -z "$entry" ] && continue |
31 | | - [ "${FIRST}" = "0" ] && echo -n ',' |
32 | | - printf '%s\n' "$entry" |
33 | | - FIRST=0 |
34 | | - done |
| 11 | +# Build "<system>/<basename> <full-path>" lines, then keep the last (latest) |
| 12 | +# row per key — sorted ascending by date, since YYYYMMDD sorts lexically. |
| 13 | +LANG="" ls -1 */results/*/*.json \ |
| 14 | + | grep -Ev '^(hardware|versions|gravitons)/' \ |
| 15 | + | sort \ |
| 16 | + | awk -F/ '{ print $1"/"$NF" "$0 }' \ |
| 17 | + | awk '{ latest[$1] = $2 } END { for (k in latest) print latest[k] }' \ |
| 18 | + | sort \ |
| 19 | + | while read -r file |
| 20 | +do |
| 21 | + if ! entry=$(jq --compact-output --arg src "$file" \ |
| 22 | + 'select((.tags // []) | index("historical") | not) | . + {"source": $src}' \ |
| 23 | + "$file"); then |
| 24 | + echo "Error in $file — skipping" >&2 |
| 25 | + continue |
| 26 | + fi |
| 27 | + [ -z "$entry" ] && continue |
| 28 | + [ "${FIRST}" = "0" ] && echo -n ',' |
| 29 | + printf '%s\n' "$entry" |
| 30 | + FIRST=0 |
35 | 31 | done >> data.generated.js.new |
36 | 32 | echo '];' >> data.generated.js.new |
37 | 33 |
|
|
0 commit comments