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

Caching questionnaires and their SM #3461

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Conversation

aurangzaibumer
Copy link
Contributor

@aurangzaibumer aurangzaibumer commented Aug 23, 2024

IMPORTANT: Where possible all PRs must be linked to a Github issue

Fixes [link to issue]

image

Engineer Checklist

  • I have written Unit tests for any new feature(s) and edge cases for bug fixes
  • I have added any strings visible on UI components to the strings.xml file
  • I have updated the CHANGELOG.md file for any notable changes to the codebase
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the project's style guide
  • I have built and run the FHIRCore app to verify my change fixes the issue and/or does not break the app
  • I have checked that this PR does NOT introduce breaking changes that require an update to Content and/or Configs? If it does add a sample here or a link to exactly what changes need to be made to the content.

Code Reviewer Checklist

  • I have verified Unit tests have been written for any new feature(s) and edge cases
  • I have verified any strings visible on UI components are in the strings.xml file
  • I have verifed the CHANGELOG.md file has any notable changes to the codebase
  • I have verified the solution has been implemented in a configurable and generic way for reuseable components
  • I have built and run the FHIRCore app to verify the change fixes the issue and/or does not break the app

@aurangzaibumer aurangzaibumer self-assigned this Aug 23, 2024
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 43.47826% with 13 lines in your changes missing coverage. Please review.

Project coverage is 28.1%. Comparing base (83bb186) to head (72f8120).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...e/quest/ui/questionnaire/QuestionnaireViewModel.kt 0.0% 12 Missing ⚠️
...register/fhircore/engine/datastore/ContentCache.kt 75.0% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main   #3461     +/-   ##
=========================================
+ Coverage     27.2%   28.1%   +0.8%     
- Complexity     756     760      +4     
=========================================
  Files          278     277      -1     
  Lines        14219   13762    -457     
  Branches      2581    2490     -91     
=========================================
- Hits          3880    3868     -12     
+ Misses        9801    9358    -443     
+ Partials       538     536      -2     
Flag Coverage Δ
geowidget 15.4% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ster/fhircore/engine/task/FhirCarePlanGenerator.kt 78.6% <100.0%> (+0.4%) ⬆️
...tregister/fhircore/quest/ui/login/LoginActivity.kt 7.8% <100.0%> (+1.9%) ⬆️
...register/fhircore/engine/datastore/ContentCache.kt 75.0% <75.0%> (ø)
...e/quest/ui/questionnaire/QuestionnaireViewModel.kt 2.8% <0.0%> (-0.5%) ⬇️

... and 33 files with indirect coverage changes

@aurangzaibumer aurangzaibumer marked this pull request as ready for review September 2, 2024 08:34
@ndegwamartin
Copy link
Contributor

@aurangzaibumer could we add a unit test for the ViewModel itself? You can mock anything you don't need/already tested in the Cache test if need be.

@dubdabasoduba dubdabasoduba changed the title [WIP] Caching questionnaires and their SM Caching questionnaires and their SM Sep 2, 2024
ContentCache.getResource(ResourceType.Questionnaire.name + "/" + questionnaireConfig.id),
)
Assert.assertNotNull(questionnaire)
Assert.assertEquals(questionnaireConfig.id, questionnaire?.id?.extractLogicalIdUuid())
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets add a verify assertion here to verify that the
defaultRepository.loadResource<Questionnaire>(questionnaireConfig.id) method was not called (i.e. was called zero times)

Copy link
Contributor

Choose a reason for hiding this comment

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

And we can probably split this to 2 unit tests to get better coverage for the changes in this class.

  • Test case 1 to test for when the questionnaire is Found in the cache
  • Test case 2 to test for when the questionnaire is Not Found in the cache

So basically use the:

val questionnaire =
      questionnaireViewModel.retrieveQuestionnaire(
        questionnaireConfig = questionnaireConfig,
      ) 

method as the focus of the test case and leave out the ContentCache.save invocations since those are already tested in the ContentCacheTest class

Comment on lines 655 to 661
structureMapUrl?.substringAfterLast("/")?.let { smID ->
ContentCache.getResource(ResourceType.StructureMap.name + "/" + smID)?.let {
it as StructureMap
}
?: run {
defaultRepository.loadResource<StructureMap>(smID)?.also {
ContentCache.saveResource(smID, it)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add some test cases for the Structure Map caching as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants