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

Handle duplicates with same allow value to avoid further duplicates with discrepancies #757

Closed
mahalakshme opened this issue Jul 16, 2024 · 1 comment
Labels

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Jul 16, 2024

Context:

  • Currently there are around 100 duplicates with discrepancies(different allow values). As part of Queries to fix duplicate privileges #746, they will be dealt with. But there are duplicates with same allow value. If users update the value from webapp, it will update only one of the duplicates and result in more discrepancies.
  • It is taking more time to identify the active orgs and the right privilege values. More discrepancies will lead to vicious cycle where we are unable to progress in this task:

AC:

  • Execute a query such that we retain only the latest group privilege with the same allow value as the duplicates. For the rest update, allow to false and voided to true along with audit info.
  • Make sure not to void the duplicates with discrepancies.

Sample query:

WITH group_privileges_duplicates AS (
    SELECT ROW_NUMBER() OVER
        (PARTITION BY group_id,privilege_id,subject_type_id,program_id,program_encounter_type_id,encounter_type_id,checklist_detail_id,allow
            ORDER BY id desc) AS rn FROM group_privilege where is_voided=false
) update group_privilege SET is_voided=true, allow = false, last_modified_date_time={}, last_modified_by_id={} FROM group_privileges_duplicates where id in (
select id from group_privileges_duplicates WHERE rn > 1);
@mahalakshme mahalakshme converted this from a draft issue Jul 16, 2024
@mahalakshme mahalakshme moved this from In Analysis to Ready in Avni Product Jul 16, 2024
@mahalakshme mahalakshme changed the title Void duplicates with same allow value to avoid further duplicates with discrepencies Handle duplicates with same allow value to avoid further duplicates with discrepancies Jul 16, 2024
@mahalakshme mahalakshme moved this from Ready to In Analysis in Avni Product Jul 16, 2024
@mahalakshme mahalakshme moved this from In Analysis to Ready in Avni Product Jul 16, 2024
@mahalakshme mahalakshme moved this from Ready to In Analysis in Avni Product Jul 16, 2024
@mahalakshme
Copy link
Contributor Author

not needed since ran n the prod

@github-project-automation github-project-automation bot moved this from In Analysis to Done in Avni Product Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

1 participant