Skip to content

Commit

Permalink
remove studyset from study endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkent committed Jun 20, 2023
1 parent 0209e7d commit d174469
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
2 changes: 0 additions & 2 deletions store/neurostore/resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ def view_search(self, q, args):
def join_tables(self, q):
"join relevant tables to speed up query"
q = q.options(joinedload('analyses'))
q = q.options(joinedload('studyset_studies').options(joinedload('studyset')))

return q

def serialize_records(self, records, args):
Expand Down
6 changes: 3 additions & 3 deletions store/neurostore/schemas/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ class StudySchema(BaseDataSchema):
source_id = fields.String(
dump_only=True, metadata={"db_only": True}, allow_none=True
)
studysets = fields.Nested(
"StudySetStudyInfoSchema", dump_only=True, metadata={"db_only": True}, many=True
)
# studysets = fields.Nested(
# "StudySetStudyInfoSchema", dump_only=True, metadata={"db_only": True}, many=True
# )
source_updated_at = fields.DateTime(
dump_only=True, metadata={"db_only": True}, allow_none=True
)
Expand Down
34 changes: 17 additions & 17 deletions store/neurostore/tests/api/test_studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,23 @@ def test_delete_studies(auth_client, ingest_neurosynth, session):
assert Analysis.query.filter_by(id=analysis).first() is None


def test_getting_studysets_by_owner(auth_clients, user_data):
client1 = auth_clients[0]
id1 = client1.username
user_studysets_db = Studyset.query.filter_by(user_id=id1).all()
all_studysets_db = Studyset.query.all()
non_user_studysets_db = list(set(all_studysets_db) - set(user_studysets_db))
all_studysets = client1.get("/api/studies/")

for study in all_studysets.json["results"]:
for studyset in study["studysets"]:
assert studyset["id"] in [as_db.id for as_db in all_studysets_db]

filtered_studysets = client1.get(f"/api/studies/?studyset_owner={id1}")
for study in filtered_studysets.json["results"]:
for studyset in study["studysets"]:
assert studyset["id"] in [us_db.id for us_db in user_studysets_db]
assert studyset["id"] not in [nus_db.id for nus_db in non_user_studysets_db]
# def test_getting_studysets_by_owner(auth_clients, user_data):
# client1 = auth_clients[0]
# id1 = client1.username
# user_studysets_db = Studyset.query.filter_by(user_id=id1).all()
# all_studysets_db = Studyset.query.all()
# non_user_studysets_db = list(set(all_studysets_db) - set(user_studysets_db))
# all_studysets = client1.get("/api/studies/")

# for study in all_studysets.json["results"]:
# for studyset in study["studysets"]:
# assert studyset["id"] in [as_db.id for as_db in all_studysets_db]

# filtered_studysets = client1.get(f"/api/studies/?studyset_owner={id1}")
# for study in filtered_studysets.json["results"]:
# for studyset in study["studysets"]:
# assert studyset["id"] in [us_db.id for us_db in user_studysets_db]
# assert studyset["id"] not in [nus_db.id for nus_db in non_user_studysets_db]


@pytest.mark.parametrize("param", ["true", "false", "doi", "name", "pmid"])
Expand Down

0 comments on commit d174469

Please sign in to comment.