#!/bin/sh
set -e
cd "`dirname "$0"`"

export METRICS_UTILITY_REPORT_TYPE="RENEWAL_GUIDANCE"
export METRICS_UTILITY_SHIP_PATH="./out"
export METRICS_UTILITY_SHIP_TARGET="controller_db"

if ! pg_isready -h localhost; then
  echo "run-s3-gather-build: DB not ready, run make compose first"
  exit 1
fi

TIME=`command -v gtime >/dev/null 2>&1 && echo 'gtime' || echo '/usr/bin/time'`
$TIME --format='\n\nmemory %MK\ncpu %P\ntime %es\n\n' \
uv run ./manage.py build_report --since=12months --ephemeral=1month --force "$@"

set -x
ls -lR out/reports/`date +%Y`/
