Skip to content

Commit

Permalink
Merge pull request #146 from natefoo/fix-archivable-histories
Browse files Browse the repository at this point in the history
Exclude deleted/purged and fix size calculation in archivable-histories query
  • Loading branch information
hexylena authored Jan 25, 2024
2 parents 800787e + 85f3309 commit e087eff
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions parts/22-query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5029,18 +5029,14 @@ query_archivable-histories() { ##? [--user-last-active=360] [--history-last-acti
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
extra_joins='
JOIN dataset on history_dataset_association.dataset_id = dataset.id'
extra_conds='AND NOT history_dataset_association.purged
extra_conds='AND NOT dataset.deleted
AND NOT dataset.purged'
group_by='GROUP BY
history.id, galaxy_user.id
'
fi

email=$(gdpr_safe galaxy_user.email email)
Expand All @@ -5055,13 +5051,19 @@ query_archivable-histories() { ##? [--user-last-active=360] [--history-last-acti
FROM
history
JOIN galaxy_user ON history.user_id = galaxy_user.id
JOIN history_dataset_association on history.id = history_dataset_association.history_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'
AND NOT history.deleted
AND NOT history.purged
AND NOT history_dataset_association.deleted
AND NOT history_dataset_association.purged
AND history.update_time < now() - interval '$arg_history_last_active minutes'
AND galaxy_user.update_time < now() - interval '$arg_user_last_active minutes'
$extra_conds
$group_by
GROUP BY
history.id, galaxy_user.id
ORDER BY
user_age ASC,
galaxy_user.email ASC,
Expand Down

0 comments on commit e087eff

Please sign in to comment.