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

Setup datastore interface #2917

Merged
merged 23 commits into from
Dec 19, 2023
Merged

Setup datastore interface #2917

merged 23 commits into from
Dec 19, 2023

Conversation

kelvin-ngure
Copy link
Contributor

@kelvin-ngure kelvin-ngure commented Dec 11, 2023

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

Fixes #2921

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

Sorry, something went wrong.

- Create delegate for providing practitionerPreferences to demonstrate proto datastore

- Create primitives Preference Store to store all primitives on the same datastore and also demonstrate preferences datastore

Create a serializer and wrapper data class for the Practitioner details to enable them to be stored to disk
Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Merging #2917 (6bbdf2b) into main (ad3a737) will increase coverage by 2.2%.
Report is 124 commits behind head on main.
The diff coverage is 64.7%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main   #2917     +/-   ##
=========================================
+ Coverage     64.5%   66.8%   +2.2%     
- Complexity    1075    1115     +40     
=========================================
  Files          218     229     +11     
  Lines         9635   10513    +878     
  Branches      1897    1926     +29     
=========================================
+ Hits          6218    7025    +807     
- Misses        2234    2256     +22     
- Partials      1183    1232     +49     
Flag Coverage Δ
engine 70.1% <66.3%> (-2.6%) ⬇️
geowidget 65.5% <33.3%> (+1.1%) ⬆️
quest 64.6% <63.9%> (+5.7%) ⬆️

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

Files Coverage Δ
...ngine/configuration/view/CompoundTextProperties.kt 100.0% <ø> (ø)
...gine/configuration/workflow/ApplicationWorkflow.kt 100.0% <100.0%> (ø)
.../fhircore/engine/domain/model/QuestionnaireType.kt 100.0% <100.0%> (ø)
...r/fhircore/engine/domain/model/RoundingStrategy.kt 100.0% <100.0%> (ø)
...martregister/fhircore/engine/sync/AppSyncWorker.kt 100.0% <ø> (ø)
...r/fhircore/engine/task/FhirResourceExpireWorker.kt 100.0% <100.0%> (ø)
...fhircore/engine/task/FhirTaskStatusUpdateWorker.kt 100.0% <100.0%> (ø)
...g/smartregister/fhircore/engine/ui/theme/Colors.kt 100.0% <100.0%> (ø)
...gister/fhircore/engine/util/SharedPreferenceKey.kt 100.0% <100.0%> (ø)
...rcore/engine/util/extension/FhirEngineExtension.kt 80.0% <100.0%> (+2.8%) ⬆️
... and 90 more

... and 28 files with indirect coverage changes

kelvin-ngure and others added 3 commits December 11, 2023 16:59
- Combined different object into one to prevent repitition of functions and allow readability. Concerns on write performance to be discussed

- Added DataStoresRespository to provide an interface for the DataStore Helper

- Added extra primitive data and extra structured data to experiment with multiple objects being added to the data stores
- Put all datastore delegates in one file. They will be provided to the repository through Hilt

- Remove data store initialization Singletons

- Move Data store keys to repository

- Begin writing explicit write functions for the dataStore to prevent exposing keys and write errors. Needs discussion
@ellykits ellykits added the Work In Progress Describes an items that is not complete. Mostly used for scoping issues of discussions label Dec 14, 2023
- Separate Proto and Preferences data stores

- Move Context datastore extensions from singular file to top of respective classes

- Remove @provides in Core module. @singleton is sufficient

- Fix dependency insertion in gradle

- Remove data class for storing all primitives. All primitives now inserted individually

- Make preferences read function to accept delegate to prevent writing a different read for each preference stored
@kelvin-ngure kelvin-ngure force-pushed the setup-datastore-interface branch from 8fc346a to dd998c1 Compare December 18, 2023 09:39
@kelvin-ngure kelvin-ngure force-pushed the setup-datastore-interface branch from 7f4d70b to a42d2ac Compare December 18, 2023 11:56
@kelvin-ngure kelvin-ngure marked this pull request as ready for review December 18, 2023 13:59
Copy link
Collaborator

@ellykits ellykits left a comment

Choose a reason for hiding this comment

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

This PR looks great 👍 . Good job @kelvin-ngure and @DebbieArita. Can we provide sample code usages of the DataStore in the docs?

@kelvin-ngure kelvin-ngure merged commit cb8548e into main Dec 19, 2023
@kelvin-ngure kelvin-ngure deleted the setup-datastore-interface branch December 19, 2023 11:38
qiarie pushed a commit that referenced this pull request Jan 15, 2025
* Add datastore and preferences datastore dependencies

* Create datastores provider

- Create delegate for providing practitionerPreferences to demonstrate proto datastore

- Create primitives Preference Store to store all primitives on the same datastore and also demonstrate preferences datastore

Create a serializer and wrapper data class for the Practitioner details to enable them to be stored to disk

* Redesign StoresProvider and add Repository

- Combined different object into one to prevent repitition of functions and allow readability. Concerns on write performance to be discussed

- Added DataStoresRespository to provide an interface for the DataStore Helper

- Added extra primitive data and extra structured data to experiment with multiple objects being added to the data stores

* Redesign architecture

- Put all datastore delegates in one file. They will be provided to the repository through Hilt

- Remove data store initialization Singletons

- Move Data store keys to repository

- Begin writing explicit write functions for the dataStore to prevent exposing keys and write errors. Needs discussion

* Proto DataStore

- Add write functions and read flows to datastore repository

- Add DataStoreHelper class as the interface for all data store functions and flows

* Add providers for the datastore repository and datastore helper into the core module

* Add sample tests for the dataStore repository

* Add tests for protoStore read and write

* Add initial refactors

- Separate Proto and Preferences data stores

- Move Context datastore extensions from singular file to top of respective classes

- Remove @provides in Core module. @singleton is sufficient

- Fix dependency insertion in gradle

- Remove data class for storing all primitives. All primitives now inserted individually

- Make preferences read function to accept delegate to prevent writing a different read for each preference stored

* Add tests for Proto DataStore and Preference DataStore

* Revert lost changes

* Revert lost code

* Re-add lost documentation

* Code cleanup

* Code cleanup

* Update docs/engineering/android-app/datastore/datastore.mdx

Co-authored-by: Elly Kitoto <[email protected]>

* Update docs/engineering/android-app/datastore/datastore.mdx

Co-authored-by: Elly Kitoto <[email protected]>

* Update docs/engineering/android-app/datastore/datastore.mdx

Co-authored-by: Elly Kitoto <[email protected]>

* Rename data classes

---------

Co-authored-by: Elly Kitoto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Work In Progress Describes an items that is not complete. Mostly used for scoping issues of discussions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup Preferences DataStore and Proto DataStore Interface
3 participants