From 6d33105ca0d7762280c06f92e56321f09d50a636 Mon Sep 17 00:00:00 2001 From: James Kent Date: Mon, 11 Sep 2023 20:41:00 -0500 Subject: [PATCH] [FIX] nick feedback (#589) * fix id and add username * test for inclusion of id --- store/neurostore/models/data.py | 7 +++++++ store/neurostore/schemas/data.py | 3 ++- store/neurostore/tests/api/test_base_studies.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/store/neurostore/models/data.py b/store/neurostore/models/data.py index e80f024a9..0879edb7b 100644 --- a/store/neurostore/models/data.py +++ b/store/neurostore/models/data.py @@ -73,6 +73,13 @@ class Studyset(BaseMixin, db.Model): backref=backref("studysets", lazy="dynamic"), ) annotations = relationship("Annotation", cascade="all, delete", backref="studyset") + __ts_vector__ = db.Column( + TSVector(), + db.Computed( + "to_tsvector('english', coalesce(name, '') || ' ' || coalesce(description, ''))", + persisted=True, + ), + ) class Annotation(BaseMixin, db.Model): diff --git a/store/neurostore/schemas/data.py b/store/neurostore/schemas/data.py index 3a0550786..3ca475abe 100644 --- a/store/neurostore/schemas/data.py +++ b/store/neurostore/schemas/data.py @@ -51,11 +51,12 @@ def _serialize(self, value, attr, obj, **ser_kwargs): return nested_schema.dump(value, many=self.many) elif self.context.get("info"): info_fields = [ - "id", + "_id", "updated_at", "created_at", "source", "user", + "username", "studysets", "has_coordinates", "has_images", diff --git a/store/neurostore/tests/api/test_base_studies.py b/store/neurostore/tests/api/test_base_studies.py index 8dcb11a88..02b60741d 100644 --- a/store/neurostore/tests/api/test_base_studies.py +++ b/store/neurostore/tests/api/test_base_studies.py @@ -50,7 +50,7 @@ def test_info_base_study(auth_client, ingest_neurosynth, session): assert single_info_resp.status_code == 200 assert single_reg_resp.status_code == 200 - assert "updated_at" in single_info_resp.json["versions"][0] + assert "id" in single_info_resp.json["versions"][0] assert isinstance(single_reg_resp.json["versions"][0], str)