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(#648): add --disable-users command for merge-contacts action #649

Merged
merged 51 commits into from
Dec 16, 2024

Conversation

kennsippell
Copy link
Member

@kennsippell kennsippell commented Nov 29, 2024

Description

When --disable-users option is present during merge-contacts

  1. Look for deleted docs in json_docs folder during upload-docs action
  2. Look for users having facility_id which matches the deleted doc id
  3. Removes the id from the user's list of facility_ids
  4. Updates the user as appropriate (deletes it if no facility_ids remain)

#648
Base branch is #647

Code review items

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

License

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

@kennsippell kennsippell requested a review from jkuester November 29, 2024 04:47
@kennsippell kennsippell requested review from sugat009 and removed request for jkuester December 10, 2024 19:32
Base automatically changed from 373-merge-contacts-options to main December 11, 2024 21:28
@kennsippell
Copy link
Member Author

kennsippell commented Dec 12, 2024

@sugat009 I'm really sorry about this, but I just realised that the difference between this and #652 would technically be a breaking change because of an interface change. I need to bring some code from that change forward into this pull request.

I think this work stands alone now and can evolve into #652 seamlessly. It is also possible that it might just make sense to review #652 against main. I'll let you decide how you want to proceed!

Changes since your last review:

  1. The --disable-users is a parameter which is passed to the merge-contacts action now, rather than being a parameter which is passed to upload-docs action. This avoids any breaking interface change.
  2. Assert if CHT Core version is less than 4.7

@kennsippell kennsippell requested a review from sugat009 December 12, 2024 10:12
async function assertCoreVersion() {
const actualCoreVersion = await getValidApiVersion();
if (semver.lt(actualCoreVersion, '4.7.0-dev')) {
throw Error(`CHT Core Version 4.7.0 or newer is required to use --disable-users options. Version is ${actualCoreVersion}.`);
Copy link
Member

Choose a reason for hiding this comment

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

question: I've noticed an inconsistency in the command structure. The disable-users argument was moved from the disable-users command to the merge-contacts command. However, after reviewing the merge-contacts command, I don't see a direct invocation of upload-docs.

Are we looking at a scenario where these commands should be combined, such as cht merge-contacts upload-docs --disable-users?

My concern is that running this against a CHT 4.6.0 instance might result in an error, even if the --disable-users flag isn't explicitly passed.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sugat009 You can read here about the intended use of the commands. Yes, you are right that the two need to be combined like this:

cht --local move-contacts upload-docs -- --contacts=contact_1 --parent=root

Copy link
Member Author

@kennsippell kennsippell Dec 12, 2024

Choose a reason for hiding this comment

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

My concern is that running this against a CHT 4.6.0 instance might result in an error, even if the --disable-users flag isn't explicitly passed.

I guess we have a few options:

  1. Crash against < 4.6.0 but only if deleted docs have the cht_disable_linked_users. Keep --disable-users flag on merge-contacts action and note that it is only supported by CHT Core 4.8 and above.
  2. Add --disable-users flag to upload-docs. Remove it from merge-contacts and (delete-contacts added in feat(#650): delete-contacts action #652 )
  3. Have --disable-users flag on both upload-docs and merge-contacts.

I suspect 1 is the best option?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, option 1 is the best option. Let's go with that.

Copy link
Member Author

@kennsippell kennsippell Dec 13, 2024

Choose a reason for hiding this comment

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

OK. Nice to confirm. That is what is in this PR now.

@kennsippell kennsippell requested a review from sugat009 December 12, 2024 23:21
@kennsippell kennsippell merged commit c78d3fd into main Dec 16, 2024
10 checks passed
@kennsippell kennsippell deleted the 373-upload-docs-delete-user branch December 16, 2024 18:41
@medic-ci
Copy link
Collaborator

🎉 This PR is included in version 4.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants