Controlling docs to sync with purge for a given user role

In our cht app we have c50_family->c40_chw_area->c30_supervisor_area->c20_health_area->c10_site
till now we have never before add a person to the c20_health_area but now we have create a user at a c20_health_area
When connecting with this user we have more than 30 000 docs to download to local pouchdb, and the sync never ends
I think that this could be solved with purge,
Is it possible to use purge to only sync some docs types for a given role ?
by the way, we need only task and reports from 3 forms for the tb_focal_point role from 01-02-2022

Hi @bamatic

Purging is not a solution for this high number of documents, as it still has a performance hit server-side.
I would recommend lowering replication_depth for the users at this level, and only allow them to see 1-2 levels deep. You can also control how documents beyond these levels reach your users by leveraging supervisor signoff .

We have c50_family → c40_chw_area → c30_supervisor_area → c20_health_area hierarchy and my user is at c20_health_area with role tb_focal_point, and we have a task with this condition

appliesIf: (contact, report) => {
    return getField(report, 'tb_referral') === 'true' &&
        getField(report,'cscom_area') === user.cscom_area;

So if I undetstand the user needs to filter at device level all reports one by one, we now that tb_referral is only sent by three forms, and from 03-2022
With depth:1 for tb_focal_point role we get 30 000 docs to sync, docs of entire health area since 2017 with more than 50 000 c50_family and about 250 000 patient, I mean, members of c50_family
I thinked that with depth:1 we could reach to children reports, but not to patient reports, but even if I wold be able to limit all patient report, task won’t work

If we do our tb_focal_point role an online user, this replication issue would finish ?

Hi @bamatic

Online users can’t use tasks.
After setting depth=1, and have 30k docs, you can use purging to reduce this number.
You can set the tb_referral forms to require supervisor_signoff(CouchDB replication | Community Health Toolkit), so they would reach the tb_focal_point regardless of replication depth.