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 data values persistence [DHIS2-18223] #18871

Merged
merged 6 commits into from
Oct 22, 2024

Conversation

enricocolasante
Copy link
Contributor

@enricocolasante enricocolasante commented Oct 18, 2024

The flow of persisting data values was quite complicated and error prone.
Now we are dealing with data values in Event in the same way we are dealing with attributes in Enrollment and TrackedEntity. We expect only the changed values (null value represent a DELETE).

  • dataValues field is not mapped in TrackerObjectsMapper
  • In EventPersister, for every dataValue in the payload we decide if it is a new value, if it is an update or a deletion and we deal with FileResources and ChangeLog accordingly.
  • createdAt, updatedAt, createdBy and updatedBy fields follow the same logic as implemented for all tracker objects.
  • It was possible for the client to set createdAt for a dataValue. This is a bug. https://dhis2.atlassian.net/browse/DHIS2-18252. A failing e2e test, solved by fixing this file, was showing this issue.

@muilpp muilpp requested a review from a team October 18, 2024 13:46
@teleivo
Copy link
Contributor

teleivo commented Oct 21, 2024

expect only the changed values (null value represent a DELETE)

and an empty string as well right? Here it looks like we are checking for blank, while for attributes we check for empty. Not that we have to support that but both data values and attributes should behave the same way.

@@ -117,8 +117,6 @@
"providedElsewhere": false
},
{
"updatedAt": "2019-03-04T15:12:59.209",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way for us to prevent test data to have these autogenerated fields in them?

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 am not sure.
Maybe we can find a way to have a jsonMapper just for tests in the integration tests that is going to be strict and fail if there are unknown fields.
In e2e tests that wouldn't work because we are using the view model and those fields are actually used in the output.
Anyway, I cannot think of something easy to implement.

@enricocolasante
Copy link
Contributor Author

expect only the changed values (null value represent a DELETE)

and an empty string as well right? Here it looks like we are checking for blank, while for attributes we check for empty. Not that we have to support that but both data values and attributes should behave the same way.

I agree.
Maybe even at API level we should agree on one way, like we are always considering a blank string as an empty string.
We can ask in the backend meeting if anyone has any input on that.

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

@enricocolasante enricocolasante merged commit 03c38af into master Oct 22, 2024
14 checks passed
@enricocolasante enricocolasante deleted the DHIS2-18223 branch October 22, 2024 08:24
@enricocolasante enricocolasante restored the DHIS2-18223 branch October 22, 2024 10:00
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.

3 participants