Update weekly_stats.yaml

This commit is contained in:
Alexandre
2022-12-08 21:52:28 +01:00
committed by GitHub
parent a0d54a42de
commit 9d8a233c7d

View File

@@ -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)"