From 44360547cbcb76c41648802fcf20765cca7b8bb3 Mon Sep 17 00:00:00 2001 From: James Kent Date: Thu, 22 Feb 2024 16:59:53 -0600 Subject: [PATCH 1/2] add models --- store/neurostore/models/data.py | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/store/neurostore/models/data.py b/store/neurostore/models/data.py index 6f2d16ae..ae95e9f8 100644 --- a/store/neurostore/models/data.py +++ b/store/neurostore/models/data.py @@ -50,6 +50,51 @@ def IRI(self): return f"http://neurostore.org/api/{self.__tablename__}/{self.id}" +class TagSet(BaseMixin, db.Model): + __tablename__ = "tag_sets" + + name = db.Column(db.String) + version = db.Column(db.String) + date_extracted = db.Column(db.DateTime(timezone=True)) + description = db.Column(db.String) + metadata = db.Column(JSONB) + tags = relationship( + "Tag", + backref=backref("tag_set"), + cascade="all, delete-orphan", + ) + + +class Tag(BaseMixin, db.Model): + __tablename__ = "tags" + + name = db.Column(db.String) + description = db.Column(db.String) + metadata = db.Column(JSONB) + automated = db.Column(db.Boolean) + user_id = db.Column(db.Text, db.ForeignKey("users.external_id")) + user = relationship("User", backref=backref("tags")) + values = relationship( + "TagValue", + backref=backref("tag"), + cascade="all, delete-orphan" + ) + study = relationship( + "BaseStudy", + backref=backref("tags"), + ) + + +class TagValue(BaseMixin, db.Model): + __tablename__ = "tag_values" + user_id = db.Column(db.Text, db.ForeignKey("users.external_id")) + user = relationship("User", backref=backref("tag_values")) + automated = db.Column(db.Boolean) + integer_value = db.Column(db.Integer) + float_value = db.Column(db.Float) + string_value = db.Column(db.String) + + class Studyset(BaseMixin, db.Model): __tablename__ = "studysets" @@ -139,6 +184,7 @@ class BaseStudy(BaseMixin, db.Model): has_coordinates = db.Column(db.Boolean, default=False, nullable=False) has_images = db.Column(db.Boolean, default=False, nullable=False) user_id = db.Column(db.Text, db.ForeignKey("users.external_id"), index=True) + __ts_vector__ = db.Column( TSVector(), db.Computed( From 58e8bd07674d850a9ca18a8fd108c8f8669c0d07 Mon Sep 17 00:00:00 2001 From: James Kent Date: Tue, 27 Feb 2024 12:37:09 -0600 Subject: [PATCH 2/2] review from conversation --- store/neurostore/models/data.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/store/neurostore/models/data.py b/store/neurostore/models/data.py index ae95e9f8..a0334b16 100644 --- a/store/neurostore/models/data.py +++ b/store/neurostore/models/data.py @@ -50,7 +50,25 @@ def IRI(self): return f"http://neurostore.org/api/{self.__tablename__}/{self.id}" -class TagSet(BaseMixin, db.Model): +class PipelineDescription(BaseMixin, db.Model): + __tablename__ = "pipeline_descriptions" + name = db.Column(db.String) + version = db.Column(db.String) + date_extracted = db.Column(db.DateTime(timezone=True)) + description = db.Column(db.String) + metadata = db.Column(JSONB) + tags = relationship( + "Tag", + backref=backref("tag_set"), + cascade="all, delete-orphan", + ) + study = relationship( + "BaseStudy", + backref=backref("tags"), + ) + + +class TagGroup(BaseMixin, db.Model): __tablename__ = "tag_sets" name = db.Column(db.String)