Skip to content

Commit

Permalink
Update models to include UsesCreateAndUpdateTime mixin
Browse files Browse the repository at this point in the history
For the sake of consistency, those models that have `create_time`, `update_time` and `tags` should share the same interface to update the `update_time` when tags are added or removed.
  • Loading branch information
davelopez committed Apr 30, 2024
1 parent dbdfcb4 commit 51d8743
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 8 additions & 5 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2927,7 +2927,7 @@ def prune(cls, sa_session):
session.execute(q)


class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable):
class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable, UsesCreateAndUpdateTime):
__tablename__ = "history"
__table_args__ = (Index("ix_history_slug", "slug", mysql_length=200),)

Expand Down Expand Up @@ -3094,6 +3094,9 @@ def username(self):
def count(self):
return self.hid_counter - 1

def update(self):
self._update_time = now()

def add_pending_items(self, set_output_hid=True):
# These are assumed to be either copies of existing datasets or new, empty datasets,
# so we don't need to set the quota.
Expand Down Expand Up @@ -7362,7 +7365,7 @@ def __init__(self):
self.user = None


class StoredWorkflow(Base, HasTags, Dictifiable, RepresentById):
class StoredWorkflow(Base, HasTags, Dictifiable, RepresentById, UsesCreateAndUpdateTime):
"""
StoredWorkflow represents the root node of a tree of objects that compose a workflow, including workflow revisions, steps, and subworkflows.
It is responsible for the metadata associated with a workflow including owner, name, published, and create/update time.
Expand Down Expand Up @@ -7740,7 +7743,7 @@ def log_str(self):
InputConnDictType = Dict[str, Union[Dict[str, Any], List[Dict[str, Any]]]]


class WorkflowStep(Base, RepresentById):
class WorkflowStep(Base, RepresentById, UsesCreateAndUpdateTime):
"""
WorkflowStep represents a tool or subworkflow, its inputs, annotations, and any outputs that are flagged as workflow outputs.
Expand Down Expand Up @@ -10061,7 +10064,7 @@ def equals(self, user_id, provider, authn_id, config):
)


class Page(Base, HasTags, Dictifiable, RepresentById):
class Page(Base, HasTags, Dictifiable, RepresentById, UsesCreateAndUpdateTime):
__tablename__ = "page"
__table_args__ = (Index("ix_page_slug", "slug", mysql_length=200),)

Expand Down Expand Up @@ -10175,7 +10178,7 @@ class PageUserShareAssociation(Base, UserShareAssociation):
page = relationship("Page", back_populates="users_shared_with")


class Visualization(Base, HasTags, Dictifiable, RepresentById):
class Visualization(Base, HasTags, Dictifiable, RepresentById, UsesCreateAndUpdateTime):
__tablename__ = "visualization"
__table_args__ = (
Index("ix_visualization_dbkey", "dbkey", mysql_length=200),
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/model/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def set_tags_from_list(
if flush:
with transaction(self.sa_session):
self.sa_session.commit()
if hasattr(item, "update"):
item.update()
item.update()
return item.tags

def get_tag_assoc_class(self, item_class):
Expand Down

0 comments on commit 51d8743

Please sign in to comment.