From 9d8a233c7d9094bb89d59a13f2f03d1f0397abb7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 8 Dec 2022 21:52:28 +0100 Subject: [PATCH] Update weekly_stats.yaml --- .github/workflows/weekly_stats.yaml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/weekly_stats.yaml b/.github/workflows/weekly_stats.yaml index 21386e705..4aec55179 100644 --- a/.github/workflows/weekly_stats.yaml +++ b/.github/workflows/weekly_stats.yaml @@ -3,7 +3,7 @@ name: Generate weekly stats on: schedule: - - cron: "0 0 * * 0" + - cron: "0 23 * * 5" workflow_dispatch: null jobs: stats_updater: @@ -19,14 +19,15 @@ jobs: COUNT2=0 COUNT3=0 # Make sure file exists - touch Stats - if ! grep -q "Date" Stats; then - sed -i "1i Date" Stats + file=Stats + touch "$file" + if ! grep -q "Date" "$file"; then + sed -i "1i Date" "$file" fi # Add new column - sed -i 's/^/- /' a + sed -i 's/^/- /' "$file" # Add date - sed -i "/Date/s|^-|$(date '+%Y-%m-%d')|" a + sed -i "/Date/s|^-|$(date '+%Y-%m-%d')|" "$file" # Go through all folders, add to filters if not existing # shellcheck disable=SC2086 @@ -52,24 +53,24 @@ jobs: COUNT3="$COUNT" echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))" else COUNT3="-";fi - echo "$SLUG $DOWNLOADS $COUNT1 $COUNT2 $COUNT3" >> Stats + echo "$SLUG $DOWNLOADS $COUNT1 $COUNT2 $COUNT3" >> "$file"2 # Create line if not existing - if ! grep -q "$SLUG" Stats; then - sed -ie "\$a$SLUG" Stats + if ! grep -q "$SLUG" "$file"; then + sed -ie "\$a$SLUG" "$file" # shellcheck disable=SC2046 - for i in $(seq $(head -n 1 Stats | tr -cd ' \t' | wc -c )); do + for i in $(seq $(head -n 1 $file | tr -cd ' \t' | wc -c )); do echo "$i" - sed -i "/$slug/s|^|- |" Stats + sed -i "/$slug/s|^|- |" "$file" done fi # Add data - sed -i "/$SLUG/s|^-|$DOWNLOADS|" a + sed -i "/$SLUG/s|^-|$DOWNLOADS|" "$file" fi done # Make stats - sort -k1 -r -n Stats > tmp && mv tmp Stats - #sed -i "1i Name Total armv7 amd64 aarch64" Stats + sort -k1 -r -n "$file" > tmp && mv tmp "$file" + #sed -i "1i Name Total armv7 amd64 aarch64" "$file" #TOTAL="$(awk '{SUM+=$2}END{print SUM}' Stats)" #TOTAL1="$(awk '{SUM+=$2}END{print SUM}' Stats)" #TOTAL2="$(awk '{SUM+=$2}END{print SUM}' Stats)"