diff --git a/lib/galaxy/managers/histories.py b/lib/galaxy/managers/histories.py index 9f5140c39aa..d3672fb7500 100644 --- a/lib/galaxy/managers/histories.py +++ b/lib/galaxy/managers/histories.py @@ -207,6 +207,17 @@ class HistoryManager(sharable.SharableModelManager, deletable.PurgableManagerMix self.model_class.deleted == (true() if show_deleted else false()) ) + # Handle archived histories + if show_published: + # Someone published a history and then archived it, it should still be returned + stmt = stmt.where(or_(self.model_class.archived == false(), self.model_class.published == true())) + elif show_shared: + # Someone shared a history with the current user and then archived it, it should still be returned + stmt = stmt.where(or_(self.model_class.archived == false(), self.user_share_model.user == user)) + else: + # By default, only return non-archived histories + stmt = stmt.where(self.model_class.archived == false()) + stmt = stmt.distinct() if include_total_count: