-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
Improve accuracy of target document after interval turnover #9431
Comments
One mention here that reloading the app will also write the doc to disk.
Unfortunately, because a lot of targets emit "now", the emission date for the target when we recalculate will be on the next interval, and this will result in a 0 target count for the past interval.
I think this scenario can only exist when the user has not used the device during the past interval.
I believe this is the best and maybe only viable option. |
So interval turnover happens when the app loads, but the routine writing of target documents doesn't trigger then. I think that's what you mean and we're on the same page?
Do you mean the target has
If memory serves me, the reason we didn't do this initially was that it may cause some noisey data synchronization and potentially conflicts if users login to multiple devices. If we are happy to ignore or address those concerns now, I think pursuing this would be a great solution for this issue. |
It does.
Yes. When we "ask" the rules engine to give us emissions, targets with emission date of
So when the interval turns over, we will essentially filter out ALL targets that emit for now, because they're not in the current interval.
This is correct. But to get higher accuracy, we need to commit these target docs more frequently. I'll be looking into this later today. |
We do indeed only recalculate targets for the updated context, not a full run every time. |
Correct, but the emission itself gets a timestamp as a date, the So, if we're calculating on Jul 5th, all |
Curious if your plan is to remove interval turnover as part of this change?
True, but also seems solvable. Could we add a flag to the emission like If interval turnover is still required, this could maybe provide an alternate path to implementing this where-by we refresh emissions as a step during interval turnover. |
I think we have two problems here:
So we can't trust the rules state store to be up to date when we do the interval turnover, because of (1) and we can't recalculate because of (2). I was dreaming about somehow recalculating the state on browser visibility change - so when the user puts the app in the background, but I'm afraid of indexeddb timeouts. Fixing (2) resolves scenario (1) from the original issue description. I think we need both. |
@dianabarsan MoH is keen to scale up digital payments work in Kenya by the end of November, and we feel that this will not be possible until we fix this data quality issue. Do we have estimated timelines that we can communicate to them? |
I'm currently working on this. I'm hoping this will be included in the next release (4.12). I wouldn't estimate it would take us beyond November to release. I feel positive about respecting your timeline. |
@dianabarsan sorry I erred on my update it should have been beginning of November and not end of November. |
@korirm This needs to be on user's devices by start of Nov. So we woiuld need to deploy probably no later than Oct 25th or thereabouts + working with Nairobi for a coordinated sync effort. |
I'm quite close to have this reviewed / smoke tested by the end of this week. |
FWIW the change involves recalculating tasks and targets immediately as changes occur instead as by-products of user actions or passing time. We would need to run a performance assessment to see if this is severely impactful (tagging @lorerod here, who was graciously volunteered to help, thanks @lorerod <3 ). |
This is now available for testing on 9431-always-aggregate . |
…occur (#9486) Refactors the calculation and aggregation of targets and recalculation of tasks from only being triggered when visiting certain pages to being calculated automatically when the state changes (documents are created/updated). To account for heavy recalculation cycles when multiple documents are downloaded or created, there is a 1s debounce between receiving a change and emissions recalculations trigger. Merges task and targets freshness tasks into a single one. #9431 #9432
…occur (#9486) Refactors the calculation and aggregation of targets and recalculation of tasks from only being triggered when visiting certain pages to being calculated automatically when the state changes (documents are created/updated). To account for heavy recalculation cycles when multiple documents are downloaded or created, there is a 1s debounce between receiving a change and emissions recalculations trigger. Merges task and targets freshness tasks into a single one. #9431 #9432 (cherry picked from commit dc3ef42)
Merged to master and backported to 4.13.x |
Is your feature request related to a problem? Please describe.
Target documents have a monthly interval. Because target documents are not always written (max of once per day, and only when viewing targets tab) they can be stale. When the interval ends, there is some "lazy best effort" to ensure that the previous interval's data is updated.
The digital payment system relies on the data in the previous month's target document. This month, there was a lot of variance between the "ideal" result (what would actually be calculated by targets.js for the month) vs the "actual" data written to the target document (the result of this interval turnover).
This feature suggests improvements to target documents so at least the previous month's target document is guaranteed to be the result of some deterministic predictable calculation.
Describe the solution you'd like
Can we recalculate all emissions during the interval turnover process before writing the values?
Can we run the interval turnover function even if the previous month's target document doesn't exist?
Or could we update the target document every time rules emissions are updated instead of daily when targets are viewed?
Additional context
Some scenarios
The text was updated successfully, but these errors were encountered: