From 891f3ffbcd0200e7939ae7bdffdfd84b9d191ba8 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 10 May 2023 17:04:30 +0200 Subject: [PATCH] Do not list archived histories with regular ones --- client/src/stores/historyStore.ts | 4 +++- lib/galaxy/webapps/galaxy/controllers/history.py | 2 +- lib/galaxy/webapps/galaxy/services/histories.py | 4 +++- lib/galaxy_test/api/test_histories.py | 10 ++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/client/src/stores/historyStore.ts b/client/src/stores/historyStore.ts index cf2ab2b2abd..24c41402d5e 100644 --- a/client/src/stores/historyStore.ts +++ b/client/src/stores/historyStore.ts @@ -32,7 +32,9 @@ export const useHistoryStore = defineStore("historyStore", () => { const storedHistories = ref<{ [key: string]: HistorySummary }>({}); const histories = computed(() => { - return Object.values(storedHistories.value).sort(sortByObjectProp("name")); + return Object.values(storedHistories.value) + .filter((h) => !h.archived) + .sort(sortByObjectProp("name")); }); const getFirstHistoryId = computed(() => { diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index fe7eaac31b3..00411d5c160 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -171,7 +171,7 @@ class HistoryListGrid(grids.Grid): return trans.get_history() def apply_query_filter(self, trans, query, **kwargs): - return query.filter_by(user=trans.user, importing=False) + return query.filter_by(user=trans.user, importing=False, archived=False) class SharedHistoryListGrid(grids.Grid): diff --git a/lib/galaxy/webapps/galaxy/services/histories.py b/lib/galaxy/webapps/galaxy/services/histories.py index a1694e8df39..476768099e4 100644 --- a/lib/galaxy/webapps/galaxy/services/histories.py +++ b/lib/galaxy/webapps/galaxy/services/histories.py @@ -158,7 +158,9 @@ class HistoriesService(ServiceBase, ConsumesModelStores, ServesExportStores): raise glx_exceptions.AdminRequiredException(message) else: filters += [model.History.user == current_user] - # and any sent in from the query string + # exclude archived histories + filters += [model.History.archived == false()] + # and apply any other filters filters += self.filters.parse_filters(filter_params) order_by = self._build_order_by(filter_query_params.order) diff --git a/lib/galaxy_test/api/test_histories.py b/lib/galaxy_test/api/test_histories.py index 055aa1cd34e..2f30a343156 100644 --- a/lib/galaxy_test/api/test_histories.py +++ b/lib/galaxy_test/api/test_histories.py @@ -904,3 +904,13 @@ class TestArchivingHistoriesWithoutExportRecord(ApiTestCase, BaseHistories): archive_response = self.dataset_populator.archive_history(history_id) self._assert_status_code_is(archive_response, 409) + + def test_archived_histories_are_not_listed_by_default(self): + history_id = self.dataset_populator.new_history() + archive_response = self.dataset_populator.archive_history(history_id) + self._assert_status_code_is(archive_response, 200) + assert archive_response.json()["archived"] is True + + histories = self.dataset_populator.get_histories() + for history in histories: + assert history["id"] != history_id