Are task documents indefinitely on user's devices?

I’m investigating some unexpected data related to tasks. To understand the potential impact, I want to verify whether or not this data is being shown to users. The tasks in question are all in a “Ready” status (with start, due, and end dates in the past), but I wasn’t sure if it’s possible that they have been purged or they automatically get removed at some point.

From the purge documentation, it looks like purging only removes contacts, reports, and messages. Also, the database schema documentation for tasks doesn’t mention anything about these documents ever being removed.

So… if I find a document of "type": "task" in the medic database on the server, this document is very likely to be on the user’s device, correct?

1 Like

As of CHT v3.9.0 (#6181), tasks are purged from the phone 60 days after the task has been moved into a terminal state (“Cancelled”, “Completed”, or “Failed”). This is done in Sentinel so it relies on the phone syncing the status update to the server, then being marked to be purged, and then syncing back to the phone.

A task in the “Ready” state won’t be purged. However if the due and end dates are in the past then the state should be updated on the phone, which will mean they do get purged eventually.

1 Like

Got it, thanks. I’ll create an issue to update the doc site with task purging info.

Slightly off topic but to the same end (task visibility), does the task tab display all task documents that are “Ready”, regardless of dueDate / endDate? So if there is some unexpected data (state = Ready, dueDate / endDate in the past), will that task still be displayed to the user?

Reading the source I think all tasks in the “Ready” state are shown, regardless of date.

1 Like

Stale task documents are refreshed when the user opens the task tab and then all task docs in the Ready state are displayed (as @gareth mentioned above). So the most likely reason for seeing task documents in “state Ready + endDate in the past” is that the user has not opened the task tab since the endDate - or they have not synced.

The client-side approach taken for the task framework means that the server’s data reflects what was happening on the user’s phone at the time of their last sync - so the data may not be fully fresh if the user doen’t engage or doesn’t sync.

Task documents are also refreshed when viewing a contact’s profile (which includes info about their tasks), and on an asynchronous “background thread” after the app has been open for a few minutes. The data upates which occur from these events have not synced to the server for that user.

2 Likes