Commit a70b633
authored
Add HealthService for managing health data and caching mechanisms (#79)
This pull request includes significant changes to the health data
handling and device information retrieval in the repository. The most
important changes involve refactoring the `BaseLocalHealthImpl` class,
updating the `DeviceInfoRepositoryImpl` class, and modifying the
`StreakRepositoryImpl` class to use a new health service.
Refactoring and improvements to health data handling:
*
[`lib/data/repositories/base_local_health_impl.dart`](diffhunk://#diff-d65e3fe018d4f55ec02d268560a3058f224079bd55bcebd461a01bbc171e4abbR1-R171):
Introduced the `BaseLocalHealthRepoImpl` class with improved methods for
fetching health data, handling overlaps, and writing tracking data to
health. This includes methods like `getHealthDataInInterval`,
`getDistanceOfWorkoutsInInterval`, and `writeTrackingToHealth`.
*
[`lib/data/repositories/local_health_impl.dart`](diffhunk://#diff-99442f8cf53d535dc947e240c47d72949d679badbe5c1f253d9d99974446d774L1-L300):
Removed the old `LocalHealthRepoImpl` class and its methods, which have
been replaced by the new `BaseLocalHealthRepoImpl` class.
Updates to device information retrieval:
*
[`lib/data/repositories/device_info_repository_impl.dart`](diffhunk://#diff-43201840425b81fa4da9d0288f18d570d606c925360655e6a514648e699d9696L15-R15):
Changed the logic for setting the installation date and getting the last
opened date to use the current date instead of a date 30 days ago.
[[1]](diffhunk://#diff-43201840425b81fa4da9d0288f18d570d606c925360655e6a514648e699d9696L15-R15)
[[2]](diffhunk://#diff-43201840425b81fa4da9d0288f18d570d606c925360655e6a514648e699d9696L33-R33)
Modifications to streak repository:
*
[`lib/data/repositories/streak_repository_impl.dart`](diffhunk://#diff-a37166ebc82c76ca34e48751e335bc8caf6c49f725d4e09b45f8bbed14f169c1L5-L7):
Replaced the `LocalHealthRepository` dependency with `HealthServiceImpl`
and updated the logic to use this new service for fetching steps and
other health data.
[[1]](diffhunk://#diff-a37166ebc82c76ca34e48751e335bc8caf6c49f725d4e09b45f8bbed14f169c1L5-L7)
[[2]](diffhunk://#diff-a37166ebc82c76ca34e48751e335bc8caf6c49f725d4e09b45f8bbed14f169c1L21-R22)
[[3]](diffhunk://#diff-a37166ebc82c76ca34e48751e335bc8caf6c49f725d4e09b45f8bbed14f169c1L138-R136)
[[4]](diffhunk://#diff-a37166ebc82c76ca34e48751e335bc8caf6c49f725d4e09b45f8bbed14f169c1L163-R162)
[[5]](diffhunk://#diff-a37166ebc82c76ca34e48751e335bc8caf6c49f725d4e09b45f8bbed14f169c1L255-R254)
- Replace current local_health_impl.dart with a new caching approach
- Add healthService, that either requests flutter health data from
local_health or returns the cached data16 files changed
Lines changed: 615 additions & 366 deletions
File tree
- lib
- data
- repositories
- service
- domain
- repositories
- service
- presentation
- activities
- details/view_model
- list/view_model
- challenges/provider
- today/view_model
- tracking/view_model
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
0 commit comments