feat(hydra-cleaner): log deletion candidates/remaining

This commit is contained in:
wpetit 2025-03-06 10:09:10 +01:00
parent fedf44a062
commit cc14a8d017

View File

@ -66,6 +66,18 @@ where table_schema = 'public'
order by 4 desc;
EOF
log "Identifying total candidates for deletion:"
psql "${DSN}" <<EOF
SELECT count(login_challenge)
FROM hydra_oauth2_flow
WHERE login_challenge = ANY (
array(
SELECT login_challenge
FROM hydra_oauth2_flow
WHERE requested_at < '${BEFORE_DATE}'
)
);
EOF
REMAINING_ELMTS="${LIMIT}"
while [ "${REMAINING_ELMTS}" -gt 0 ]; do
@ -101,6 +113,19 @@ EOF
fi
done
log "Candidates remaining after deletion:"
psql "${DSN}" <<EOF
SELECT count(login_challenge)
FROM hydra_oauth2_flow
WHERE login_challenge = ANY (
array(
SELECT login_challenge
FROM hydra_oauth2_flow
WHERE requested_at < '${BEFORE_DATE}'
)
);
EOF
log "Final estimated size:"
psql "${DSN}" <<EOF