Skip to content
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

feat(#6543): disable aggregate targets for users with multiple facility_ids #9099

Open
wants to merge 7 commits into
base: 6543-multi-facility
Choose a base branch
from

Conversation

latin-panda
Copy link
Contributor

@latin-panda latin-panda commented May 7, 2024

Description

  • Users with many associated facilities cannot see target aggregates

  • To assign more than one facility to a user:

    • Go to couchdb, find the _users database, find the offline user org.couchdb:<username>
    • Make facility_id an array and add the IDs: "facility_id: [ "id-1", "id-2" ]
      • the facility should be at the same level in the hierarchy.
    • Go find the medic database, find the offline user org.couchdb:<username>
    • Make facility_id an array and add the IDs: "facility_id: [ "id-1", "id-2" ]. It should match with the one in _users db.

Videos:

  • The can_aggregate_targets is disabled. Users with 1 and with many associated facilities cannot see the aggregate targets page.
permission-disabled.mp4
  • The can_aggregate_targets is enabled. Users with 1 associated facility can see the page, but those with many associated facilities cannot see the aggregate targets page.
permission-enabled.mp4

#6543

Code review checklist

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

Compose URLs

If Build CI hasn't passed, these may 404:

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@latin-panda latin-panda changed the base branch from master to 6543-multi-facility May 7, 2024 10:32
@@ -12,8 +12,7 @@ export class AnalyticsFilterComponent implements AfterContentInit, AfterContentC
subscriptions: Subscription = new Subscription();

constructor(
private router: Router,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused dependency

}

const facilityIds = await this.getUserFacilityIds();
return !!facilityIds && facilityIds.length <= 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried facilityIds?.length <= 1, but the static checks didn't like it.

@latin-panda
Copy link
Contributor Author

@Benmuiruri @lorerod please have a look at this small PR. I attached a couple of videos and added coverage with unit tests.

Thanks!

Copy link
Contributor

@Benmuiruri Benmuiruri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @latin-panda

I expected the user who should have multiplefacility_ids is the CHA not the CHP. In your video I see you enabling and disabling can_aggregate_targets for the CHP. I wonder, are the users in your test CHA or a CHP ?

However, in my test I have tested with CHA and it works as expected. The one with 1 facility_id is the only one who can see targets_aggregate

@latin-panda
Copy link
Contributor Author

are the users in your test CHA or a CHP ?

@Benmuiruri the users in my video are CHP

Copy link
Contributor

@lorerod lorerod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding an end-to-end test in /tests/e2e/default/targets/target-aggregates.wdio-spec.js for users with multiple facility IDs?

@latin-panda latin-panda requested a review from lorerod May 9, 2024 11:42
@latin-panda
Copy link
Contributor Author

@lorerod thanks for reviewing! I have added the e2e test

Copy link
Contributor

@lorerod lorerod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @latin-panda !

@latin-panda
Copy link
Contributor Author

@Benmuiruri, this has been rebased, and the tests are working. It's ready. Just waiting for 6543-multi-facility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable Aggregate Targets for users with multiple facility_ids
3 participants