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

chore: Clean up tracker domain objects [DHIS2-18222] #18857

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

enricocolasante
Copy link
Contributor

@enricocolasante enricocolasante commented Oct 17, 2024

This PR is removing all fields that are not used in tracker importer. Most of them they were there because our view model, that in the web layer is mapped to tracker model, is used for input and output and contains read-only fields that are not necessary in tracker importer.

In particular:

  • Tracker model is flat (tracker objects are not nested, it is flattened in the controller BodyConverter ), so all the nesting entities can be safely removed.
  • All system-created fields are not needed in tracker model (createdAt, createdBy, etc...)
  • deleted flag cannot be modified and importer is only dealing with not deleted objects.

Next steps
DataValue fields are going to be removed in https://dhis2.atlassian.net/browse/DHIS2-18223

@enricocolasante enricocolasante marked this pull request as ready for review October 18, 2024 07:56
@enricocolasante enricocolasante requested a review from a team as a code owner October 18, 2024 07:56
@teleivo
Copy link
Contributor

teleivo commented Oct 18, 2024

Most of them they were there because our view model, that in the web layer is mapped to tracker model, is used for input and output and contains read-only fields that are not necessary in tracker importer.

maybe to clarify: our view models are fairly new and are used as the types for import/export. The view models originated from the domain models. We likely forgot to delete those domain model fields when we created the view models.

@@ -96,10 +86,6 @@ public class Event implements TrackerDto, Serializable {

@JsonProperty private User assignedUser;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can users set completedBy/At?

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 asked this myself and then forgot to go forward with that.
The completedBy in my head shouldn't be set by the user, you shouldn't be able to do stuff on behalf of others.
The createdAt could be something that the user needs to set. I asked @vgarciabnz how it is expected to work when Android is synching.

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 had a chat with Victor another with Ameen and Joakim. completedAt could be set by the user so I will put it back for Enrollment and leave it as it is for Event.
I am going to do it in next PR though

@@ -174,7 +174,7 @@ void testGetJobRunErrors_ListIncludeInput() throws InterruptedException {
// language=JSON
String expected =
"""
{"trackedEntities":[{"trackedEntity":"sHH8mh1Fn0z","trackedEntityType":{"idScheme":"UID","identifier":"nEenWmSyUEp"},"orgUnit":{"idScheme":"UID","identifier":"DiszpKrYNg7"},"inactive":false,"deleted":false,"potentialDuplicate":false,"relationships":[],"attributes":[],"enrollments":[]}],"enrollments":[],"events":[],"relationships":[]}""";
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change affect jobs? If so should we add a migration to remove unnecessary data? Or would such jobs be removed after a while anyway

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 never know 😬
@jbee Can you help us here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Tracker import jobs are removed a day after they have been running. I am not quite sure what changed with regards to the job but I think you removed something which should be fine. If the job was stored with more parameter data than it later executes this still works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jbee .

@enricocolasante enricocolasante enabled auto-merge (squash) October 21, 2024 08:58
Copy link

@enricocolasante enricocolasante merged commit 24b1656 into master Oct 21, 2024
14 checks passed
@enricocolasante enricocolasante deleted the DHIS2-18222 branch October 21, 2024 09:11
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.

4 participants