Skip to content

Commit

Permalink
Cache and provide in-memory fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Jul 9, 2024
1 parent 3b65665 commit 0be837e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6501,11 +6501,20 @@ def attribute_columns(column_collection, attributes, nesting_level=None):

@property
def elements_deleted(self):
stmt = self._build_nested_collection_attributes_stmt(
hda_attributes=("deleted",), dataset_attributes=("deleted",)
)
stmt = exists(stmt).where(or_(HistoryDatasetAssociation.deleted == true(), Dataset.deleted == true()))
return object_session(self).execute(select(stmt)).scalar()
if not hasattr(self, "_elements_deleted"):
if session := object_session(self):
stmt = self._build_nested_collection_attributes_stmt(
hda_attributes=("deleted",), dataset_attributes=("deleted",)
)
stmt = stmt.exists().where(or_(HistoryDatasetAssociation.deleted == true(), Dataset.deleted == true()))
self._elements_deleted = session.execute(select(stmt)).scalar()
else:
self._elements_deleted = False
for dataset_instance in self.dataset_instances:
if dataset_instance.deleted or dataset_instance.dataset.deleted:
self._elements_deleted = True
break
return self._elements_deleted

@property
def dataset_states_and_extensions_summary(self):
Expand Down

0 comments on commit 0be837e

Please sign in to comment.