diff --git a/parts/22-query.sh b/parts/22-query.sh index 409b24b..79188f8 100644 --- a/parts/22-query.sh +++ b/parts/22-query.sh @@ -4999,3 +4999,71 @@ query_tools-usage-per-month() { ##? [--startmonth=-] [--endmonth= "/dev/stderr";}' | \\ + GALAXY_CONFIG_FILE=/gx/config/galaxy.yml xargs /gx/venv/bin/python3 | \\ + /gx/galaxy/scripts/secret_decoder_ring.py encode + + This outputs the total size to archive to stderr while encoding all history IDs on stdout for + consumption by API-based archival tools. + EOF + + extra_selects= + extra_joins= + extra_conds= + group_by= + if [[ -n $arg_size ]]; then + extra_selects=', + sum(dataset.total_size) AS size + ' + extra_joins='JOIN history_dataset_association on history.id = history_dataset_association.history_id + JOIN dataset on history_dataset_association.dataset_id = dataset.id' + extra_conds='AND NOT history_dataset_association.purged + AND NOT dataset.purged' + group_by='GROUP BY + history.id, galaxy_user.id + ' + fi + + email=$(gdpr_safe galaxy_user.email email) + + read -r -d '' QUERY <<-EOF + SELECT + history.id, + $email, + date(galaxy_user.update_time) user_age, + date(history.update_time) history_age + $extra_selects + FROM + history + JOIN galaxy_user ON history.user_id = galaxy_user.id + $extra_joins + WHERE + NOT history.published + AND history.update_time < now() - interval '$arg_history_last_active days' + AND galaxy_user.update_time < now() - interval '$arg_user_last_active days' + $extra_conds + $group_by + ORDER BY + user_age ASC, + galaxy_user.email ASC, + history_age ASC + EOF +}