Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TN-3291 implement caching of research data, for performance improvement #4382

Merged
merged 21 commits into from
Sep 5, 2024

Conversation

pbugni
Copy link
Collaborator

@pbugni pbugni commented Jun 4, 2024

Reports from the field - the generation of research_data has become unreliable due to time it takes to build report.

Now retaining a table of cached values, one row per questionnaire response, for a responsive report generation.

Primary concern will be with cache-invalidation, especially on an org change of research protocol or a user's consent date change.

There is now a scheduled job that runs daily, to seek out any overlooked QNRs missing from this new cache table research_data. A dry run of the prod db:

"found 92748 questionnaire responses missing from research_data cache"
[...]
""Task portal.tasks.cache_research_data_task[f87d7130-d2b2-4413-a461-61cf3ebc9594] succeeded in 32897.385058208994s"

thereafter, it will generally find zero, as we immediately update on QNR put/post.

@pep8speaks
Copy link

pep8speaks commented Jun 4, 2024

Hello @pbugni! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 785:5: E303 too many blank lines (2)

Comment last updated at 2024-09-05 20:45:35 UTC

@@ -370,7 +370,8 @@ def quote_double_quote(value):
answer['valueCoding'].get('text')
)

text_and_coded_answers.append({'valueString': text_answer})
if text_answer is not None:
Copy link
Collaborator Author

@pbugni pbugni Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivan-c this change was necessary to get tests to pass, as some results after posting an update to a questionnaire response, would show valueString: None. i can't imagine it would ever be worth saving a valueString with a value of None in a questionnaire response, would it?

those were showing up as differences in the following test:

 py.test tests/test_assessment_engine.py::TestAssessmentEngine::test_update_assessment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can't imagine it would ever be worth saving a valueString with a value of None in a questionnaire response, would it?

probably not- None/null isn't the same type as valueString anyway

@pbugni pbugni marked this pull request as ready for review June 13, 2024 03:33
@pbugni pbugni requested review from mcjustin and ivan-c June 13, 2024 03:33
Base automatically changed from feature/sequential-hard-triggers-fix to develop July 2, 2024 19:01
@pbugni pbugni force-pushed the feature/cache-reporting branch from 3c97fdf to 696a4df Compare July 2, 2024 21:18
@pbugni pbugni force-pushed the feature/cache-reporting branch 2 times, most recently from a869bf0 to c13ce5a Compare July 15, 2024 17:42
Copy link
Member

@ivan-c ivan-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@@ -370,7 +370,8 @@ def quote_double_quote(value):
answer['valueCoding'].get('text')
)

text_and_coded_answers.append({'valueString': text_answer})
if text_answer is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can't imagine it would ever be worth saving a valueString with a value of None in a questionnaire response, would it?

probably not- None/null isn't the same type as valueString anyway

@pbugni pbugni force-pushed the feature/cache-reporting branch from d8d0c47 to 1641407 Compare August 9, 2024 01:03
@pbugni pbugni force-pushed the feature/cache-reporting branch from 2df1268 to b2c9a92 Compare September 5, 2024 20:45
@pbugni pbugni merged commit c17c6ff into develop Sep 5, 2024
1 check passed
@pbugni pbugni deleted the feature/cache-reporting branch September 5, 2024 20:46
ivan-c pushed a commit that referenced this pull request Sep 10, 2024
…nt (#4382)

Reports from the field - the generation of research_data has become
unreliable due to time it takes to build report.

Now retaining a table of cached values, one row per questionnaire
response, for a responsive report generation.

Primary concern will be with cache-invalidation, especially on an org
change of research protocol or a user's consent date change.

There is now a scheduled job that runs daily, to seek out any overlooked
QNRs missing from this new cache table `research_data`. A dry run of the
prod db:
```
"found 92748 questionnaire responses missing from research_data cache"
[...]
""Task portal.tasks.cache_research_data_task[f87d7130-d2b2-4413-a461-61cf3ebc9594] succeeded in 32897.385058208994s"
```
thereafter, it will generally find zero, as we immediately update on QNR
put/post.
ivan-c pushed a commit that referenced this pull request Sep 10, 2024
…nt (#4382)

Reports from the field - the generation of research_data has become
unreliable due to time it takes to build report.

Now retaining a table of cached values, one row per questionnaire
response, for a responsive report generation.

Primary concern will be with cache-invalidation, especially on an org
change of research protocol or a user's consent date change.

There is now a scheduled job that runs daily, to seek out any overlooked
QNRs missing from this new cache table `research_data`. A dry run of the
prod db:
```
"found 92748 questionnaire responses missing from research_data cache"
[...]
""Task portal.tasks.cache_research_data_task[f87d7130-d2b2-4413-a461-61cf3ebc9594] succeeded in 32897.385058208994s"
```
thereafter, it will generally find zero, as we immediately update on QNR
put/post.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants