Skip to content

Commit

Permalink
Merge pull request #588 from sartography/dev
Browse files Browse the repository at this point in the history
remove check for when a person only has invalid study types.
  • Loading branch information
danfunk authored Dec 5, 2023
2 parents 8755bc8 + cb91c2b commit ce472f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
12 changes: 7 additions & 5 deletions crc/api/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ def user_studies():
cats = spec_service.get_categories()
StudyService.synch_with_protocol_builder_if_enabled(user, specs)
studies = StudyService().get_studies_for_user(user, categories=cats)
if len(studies) == 0:
studies = StudyService().get_studies_for_user(user, categories=cats, include_invalid=True)
if len(studies) > 0:
message = f"All studies associated with User: {user.uid} failed study validation"
raise ApiError(code="study_integrity_error", message=message)

# Disable this check - we don't want to raise this error.
# if len(studies) == 0:
# studies = StudyService().get_studies_for_user(user, categories=cats, include_invalid=True)
# if len(studies) > 0:
# message = f"All studies associated with User: {user.uid} failed study validation"
# raise ApiError(code="study_integrity_error", message=message)

results = StudySchema(many=True).dump(studies)
return results
Expand Down
5 changes: 4 additions & 1 deletion crc/services/study_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class StudyService(object):

@staticmethod
def get_pb_min_date():
pb_min_date = parser.parse(app.config['PB_MIN_DATE'])
try:
pb_min_date = parser.parse(app.config['PB_MIN_DATE'])
except Exception as e:
pb_min_date = datetime(2019, 1, 1)
return pb_min_date

def get_studies_for_user(self, user, categories, include_invalid=False):
Expand Down
2 changes: 1 addition & 1 deletion tests/study/test_study_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_get_all_studies(self, mock_studies, mock_details, mock_docs, mock_inves
num_open += 1
if study['id'] == 65432:
# This study has `null` for DATELASTMODIFIED, so we should use the value in DATECREATED
self.assertEqual('2020-02-19T14:24:55.101695+00:00', study['last_updated'])
self.assertEqual('2020-02-19T14:24:55.101695-05:00', study['last_updated'])
if study['id'] == 11111:
self.assertTrue(False,"Study 11111 is too old to be processed and imported, it should be ignored.")
db_studies_after = session.query(StudyModel).all()
Expand Down

0 comments on commit ce472f0

Please sign in to comment.