Task Data on couchdb

Hi,

I really need some help. We are having an issue right now that the tasks that is saving on the couchdb is making a duplicates.

Details:
I am trying to re-fix the task names on the tasks.js file, and somehow old task name is turned out cancelled as its state. and the new task name is automatically completed. Our problem is when we count the number of task that is completed, it turns out it was doubled or tripled.


On this diagram, you can see on last day of January 2024, the counts of task is really on the roof.
So, we investigate it, and we have a suspicion that is because of the renaming of task names.
it was like counting task by its report uuid.

@binod can you help us on this? on any suggestion to fix it?

Thank you very much and God Bless

Hi @Marcelo_De_Guzman, sorry for the late reply.

In CHT, when a task is saved, it gets the _id which looks like this:

"_id": "task~org.couchdb.user:agatha~pregReport~pregnancy-facility-visit-reminder~2~523435132468"

Here, pregnancy-facility-visit-reminder comes from the task name. When you change the task name in tasks.js, the task with the same _id is not emitted when refreshing the tasks. So the old task goes to the Cancelled state and a new task is created instead. This is an expected behavior. You can read about the task schema here:

I suggest you adjust the query/logic to count the tasks so the canceled tasks are discarded from the total count.

Also, note that the canceled tasks will eventually be purged from the CHT database users’ devices.

As of 3.9.0, task documents that are in a terminal state (Cancelled, Completed, Failed) are purged if their end_date is more than 60 days ago (relative to server date).

Hi @binod ,

Thanks for the instructions. We will try this one out.

We have a dashboard that is showing all of the tasks of the person / coordinator who do the task, and when it purges, you mean the record will be deleted?

The task records will be removed from the user’s device so that it does not impact the performance.
However, the records will remain on the server. Your dashboard should not be affected.

Sorry, my earlier response was unclear. I have updated it.