| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | export AWS_PROFILE=nixos-org |
| 6 | |
| 7 | now=$(date +%s) |
| 8 | #now=$((now - 86400)) |
| 9 | prev_week=$((now / 86400 / 7)) |
| 10 | |
| 11 | from_date_incl=$(date +%F --date="@$((prev_week * 86400 * 7 - 2 * 86400))") |
| 12 | to_date_incl=$(date +%F --date="@$((prev_week * 86400 * 7 + 5 * 86400))") |
| 13 | |
| 14 | echo "Ingesting [$from_date_incl, $to_date_incl)." |
| 15 | |
| 16 | marker="$HOME/weeks-done/$prev_week" |
| 17 | |
| 18 | if [[ -e $marker ]]; then |
| 19 | echo "Already done!" |
| 20 | exit 0 |
| 21 | fi |
| 22 | |
| 23 | mkdir -p "$(dirname "$marker")" |
| 24 | touch "$marker" |
| 25 | |
| 26 | ./ingest-raw-logs.sh "$from_date_incl" "$to_date_incl" |
| 27 | |
| 28 | ./run-queries.sh |