feat: support /tracker/event?dataElementIdScheme DHIS2-14968 #19153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
support
/tracker/events?dataElementIdScheme
EventStore
and letDefaultEventService
depend directly on the concrete implementation. As with other interfaces we've removed: only add an interface to isolate for testing purposes or if there are multiple implementations. None of these cases apply here.TrackerIdSchemeParams
toEventOperationParams
andEventQueryParams
so we can modify the SQL query only if thedataElementIdScheme
is not UIDQuery and EventDataValues
EventDataValues
are stored as JSONB in theevent.eventdatavalues
column. See https://dhis2.atlassian.net/browse/DHIS2-4477 for details on why this came to be. This means an event can have multipleEventDataValue
in one event row.EventDataValue.dataElement is of type
String
. Unlike other types of ours which have a reference to aMetadata
object.The JSONB is an object with a
dataValue
perdataElement
UIDLuckily this bug https://dhis2.atlassian.net/browse/DHIS2-10018 was fixed and we can rely on the
dataElement
keys beingUID
s only.We need to join with the
dataelement
table to get access tocode
,name
andattributevalues
. This means we need toextract/expand
theeventdatavalues
into individualeventdatavalue
objects. This leads to a event x eventdatavalues of rows. Like we would with the classical normalized model of tablesevent
,eventdatavalues
andevent_eventdatavalues
:This is the rough anatomy of an event query
Note that the subquery (with limit/offset) cannot have more than one row per event so pagination using offset and limit is correct. First attempt was changing the main subquery which was too slow as it was working on all events #19123. This change is to the parent query (as we do with notes) so events have already been filtered to one event or a page in most cases. This means we then need to "aggregate" the result set like we do with notes when idScheme !=
UID
.Latency
These measurements are made using a single curl request to a local instance with no other traffic. They do give an indication of the effect of the changed query on latency though.
dataElementIdScheme
other than UID increases latency significantly for large page sizes. This is what we have to face if we align ACL for dataValues in/tracker/events
and/tracker/events/{uid}
.idScheme=UID
idScheme=NAME&dataElementIdScheme=UID
idScheme=NAME
idScheme=UID
idScheme=NAME&dataElementIdScheme=UID
idScheme=NAME
The difference in download size with
idScheme=NAME
is likely due to some metadata not having a name which right now will not be returned.Next
default
category option/combo options when it comes to attribute values as they do not have any and users cannot add any