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

IA-3728 Create change requests from differences between two pyramids (backend model) #1836

Open
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

kemar
Copy link
Member

@kemar kemar commented Nov 28, 2024

Create change requests from differences between two pyramids (backend model).

Related JIRA tickets : IA-3728

Doc

See the design specification linked in the aforementioned JIRA ticket.

Changes

  • new DataSourceSynchronization model and admin:

    • allows to synchronize two pyramids via "change requests"
    • this model is tightly coupled with the diffing module for the logic
  • diffing module:

    • added tests (this was helpful to understand how it works)
    • fixed Dumper.dump_as_json() which was broken
    • fixed Differ.diff for groups (only groups from one side were taken into account)
    • fixed Differ.compare_fields
      • if dhis2_value is None and ref_value is not None: wasn't working when ref_value = [] (empty list) for empty groups

How to test

  1. go to /admin/iaso/datasourceversionssynchronization/add/

  2. configure a new "Data source synchronization" with two source versions that you want to synchronize

    • ensure those two source versions have differences
  3. save

  4. find the ID of the newly created "Data source synchronization"

  5. open a Django shell docker compose exec -ti iaso ./manage.py shell_plus

  6. trigger the synchronization (those steps will be handled by the future API):

    • get the "Data source synchronization" object assuming its ID is 1:

        sync = DataSourceVersionsSynchronization.objects.get(id=1)
      
    • generate the diff between the two pyramids (this allows to count how many change requests there will be):

        sync.create_json_diff()
      
    • synchronize the two pyramids and create "change requests":

        sync.synchronize_source_versions()
      
  7. go to /admin/iaso/orgunitchangerequest/

  8. filter the list by your "Data source synchronization"

  9. you should be able to see the newly created "change requests"

Print screen

admin1

admin2

@kemar kemar self-assigned this Nov 28, 2024
@kemar kemar force-pushed the IA-3728-create-change-requests-from-differences-between-two-pyramids branch from 7332ea4 to 778f5de Compare December 5, 2024 12:23
@kemar kemar force-pushed the IA-3728-create-change-requests-from-differences-between-two-pyramids branch from 81609c3 to 1c8eda3 Compare December 17, 2024 15:52
@kemar kemar changed the title IA-3728 Create change requests from differences between two pyramids (backend) IA-3728 Create change requests from differences between two pyramids (backend model) Dec 31, 2024
@kemar kemar force-pushed the IA-3728-create-change-requests-from-differences-between-two-pyramids branch from d9cbcde to 2a6d078 Compare December 31, 2024 09:36
@kemar kemar marked this pull request as ready for review December 31, 2024 10:26
@kemar kemar requested a review from madewulf December 31, 2024 13:40
iaso/admin.py Show resolved Hide resolved
iaso/models/org_unit.py Show resolved Hide resolved
iaso/models/data_source.py Show resolved Hide resolved
@kemar kemar requested a review from madewulf January 9, 2025 16:42
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.

2 participants