medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
467 stars 217 forks source link

Update client-side purging to trigger task recalculation #8037

Open dianabarsan opened 1 year ago

dianabarsan commented 1 year ago

What feature do you want to improve? Task recalculation is triggered through a couple of mechanism:

Describe the improvement you'd like Purging implies deleting documents from the user's device. However, the deletion happens when booting, before any Angular service has started, specifically to avoid changes feeds from catching up with a large stream of changes (the purged documents being deleted). The consequence for this is that local mechanism that watch the changes feed will not be notified of the change, one of these examples is recalculating tasks when older documents are deleted.

After purging, targets will get recalculated by the other mechanisms, it will just take a while and the action that triggered the recalculation will not be obvious.

To reproduce:

Ideally we would only force recalculation of relevant tasks, much like it would be as if the deletes happened while the Angular app was running and Rules-Engine would mark corresponding contacts as dirty.

Describe alternatives you've considered Leave it as it is.

Additional context Form post where a submission that was supposed to resolve a task ended up cancelling it after purging had changed the appliesIf result from true to false.

dianabarsan commented 1 year ago

This is potentially resolved by https://github.com/medic/cht-core/issues/8296.