-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add configuration to generate MeasureReports in the background (#2515) #2520
Conversation
* Add configuration to generate MeasureReports in the background * Set default report config startPeriod, remove subject from existing measureReport retrieval * Exclude Subjects from existing measure report retrieval search --------- Co-authored-by: Martin Ndegwa <ndegwamartin@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## main #2520 +/- ##
=========================================
- Coverage 65.4% 65.1% -0.3%
- Complexity 1101 1110 +9
=========================================
Files 213 215 +2
Lines 9385 9544 +159
Branches 1866 1899 +33
=========================================
+ Hits 6140 6217 +77
- Misses 2047 2120 +73
- Partials 1198 1207 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@ndegwamartin this doesn't seem like the correct fixes ref |
...org/smartregister/fhircore/engine/configuration/report/measure/MeasureReportConfiguration.kt
Outdated
Show resolved
Hide resolved
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MeasureReportConfig> { | ||
return try { | ||
LoadResult.Page(data = measureReportConfiguration.reports, prevKey = null, nextKey = null) | ||
} catch (exception: Exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we catch something more specific?
...rc/main/java/org/smartregister/fhircore/quest/data/report/measure/MeasureReportRepository.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/org/smartregister/fhircore/quest/data/report/measure/MeasureReportRepository.kt
Outdated
Show resolved
Hide resolved
android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/AppMainViewModel.kt
Outdated
Show resolved
Hide resolved
.../java/org/smartregister/fhircore/quest/ui/report/measure/worker/MeasureReportConfigWorker.kt
Outdated
Show resolved
Hide resolved
.../java/org/smartregister/fhircore/quest/ui/report/measure/worker/MeasureReportConfigWorker.kt
Outdated
Show resolved
Hide resolved
} | ||
} | ||
Timber.i("Result.success / . . . MeasureReportWorker . . ./") | ||
} catch (e: Exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a more specific exception?
.../java/org/smartregister/fhircore/quest/ui/report/measure/worker/MeasureReportConfigWorker.kt
Outdated
Show resolved
Hide resolved
.../java/org/smartregister/fhircore/quest/ui/report/measure/worker/MeasureReportConfigWorker.kt
Outdated
Show resolved
Hide resolved
* This method always sets the start and end date of the month to be the first and last day of the | ||
* current month. If you are using this worker to generate monthly reports it enqueue a new worker | ||
* at least every 24 hours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure this is correct, need to think about this a bit more to see if there's an edge case that misses data from the previous month when the date changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is actually still a problem, since it’s using “today” to figure out the current month instead of the date it was enqueued. This is what I’m thinking, if it’s the last day of the month, you run the worker, and enqueue another worker for tomorrow. Then you collect more data. That new data you collected will never appear in the previous months measure report, because by the time the enqueued measure report runs it will be tomorrow, in the next month, and that run will be for the next month.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One (simple?) solution is to have today
be set when the worker is enqueued, instead of when the worker is run. then when you enqueue a worker on the last day of the month, and proceed to collect some data, when that worker runs it will cover all the data for the previous month, during which it was enqueued.
This also seems to match expected behavior... better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created this issue to track this, #2567
d90a84e
to
21cfb9c
Compare
532b917
to
543158b
Compare
14bf673
to
4c6ae86
Compare
4c6ae86
to
b723c7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow-up tasks in #2567
#2520) * add configuration to generate MeasureReports in the background (#2515) * Add configuration to generate MeasureReports in the background * Set default report config startPeriod, remove subject from existing measureReport retrieval * Exclude Subjects from existing measure report retrieval search --------- Co-authored-by: Martin Ndegwa <ndegwamartin@users.noreply.github.com> * cleanup and notes * fix typo * remove comment * add a failing test to run eval pop measure * catch exception with bad measure url * change MeasureReportConfig to ReportConfiguration, add tests * upgrade spotless and lint, use trailing commas per new lint recs --------- Co-authored-by: Roy <84201465+roywanyaga@users.noreply.github.com> Co-authored-by: Benjamin Mwalimu <dubdabasoduba@gmail.com> Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>
IMPORTANT: Where possible all PRs must be linked to a Github issue
Fixes #2307
Engineer Checklist
strings.xml
file./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the project's style guideCode Reviewer Checklist
strings.xml
file