Files
usaco/lib/cmd/stats.sh
T

21 lines
752 B
Bash

# usaco stats
count() { [[ -d "$1" ]] && find "$1" -mindepth 1 -maxdepth 1 -type d | wc -l || echo 0; }
solved=$(count "$ROOT/solved"); solving=$(count "$ROOT/solving"); skipped=$(count "$ROOT/skipped")
now=$(date +%s); week=0; month=0
if [[ -d "$ROOT/solved" ]]; then
for d in "$ROOT/solved"/*/; do
[[ -d "$d" ]] || continue
t="$(find "$d" -type f -printf '%T@\n' | sort -n | tail -1 | cut -d. -f1)"
[[ -z "$t" ]] && continue
age=$(( now - t ))
(( age <= 7*86400 )) && week=$((week+1))
(( age <= 30*86400 )) && month=$((month+1))
done
fi
echo "Solved: $solved"
echo "Solving: $solving"
echo "Skipped: $skipped"
echo
echo "Solved in last 7 days: $week"
echo "Solved in last 30 days: $month"