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

add support for tracker v41 #156

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
Open

Conversation

eperedo
Copy link
Contributor

@eperedo eperedo commented Jan 14, 2025

📌 References

📝 Implementation

  • In v41 the tracker endpoints /tracker/trackedEntities, /tracker/events and /tracker/enrollments no longer returns the data in an instances array anymore. Now they are using a key named after the plural of the returned entity.

/tracker/trackedEntities

{
  "trackedEntities": [...]
}

/tracker/events

{
  "events": [...]
}

/tracker/enrollments

{
  "enrollments": [...]
}

In order to keep backwards compatibility and to avoid breaking changes in d2-api we'll keep the instances attribute checking for an instances array and if there's none we fall back to trackedEntities, events or enrollments according to the requested endpoint.

  • Also now the pagination information is included in a pager object:
{
  "pager": {
    "page": 3,    
    "pageSize": 2,
    "total": 373570,
    "pageCount": 186785,
  },
  "page": 3,
  "pageSize": 2,
  "total": 373570,
  "pageCount": 186785,
}

They are also keeping the pagination information outside the object for now, but it will be removed in a future release.

📹 Screenshots/Screen capture

🔥 Notes to the tester

Can you help me with a beta version, please? @adrianq

#86964a9ua

@eperedo eperedo requested review from tokland and adrianq January 15, 2025 12:29
@ifoche
Copy link
Member

ifoche commented Jan 15, 2025

Task linked: CU-86964a9ua A12: Testing and feedback

@eperedo eperedo marked this pull request as ready for review January 15, 2025 12:30
Copy link
Contributor

@tokland tokland left a comment

Choose a reason for hiding this comment

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

Some in-line comments:

};
}

type TrackedKeys = "trackedEntities" | "enrollments" | "events";
Copy link
Contributor

@tokland tokland Jan 17, 2025

Choose a reason for hiding this comment

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

type TrackedKey. It seems plural, because of the enumeration, but in fact it's describing a value that will have some of this value, not a collection.

src/api/trackerEnrollments.ts Show resolved Hide resolved
src/api/trackerTrackedEntities.ts Show resolved Hide resolved
@eperedo eperedo requested a review from tokland January 24, 2025 18:24
Copy link
Contributor

@tokland tokland left a comment

Choose a reason for hiding this comment

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

Cool, just some minor changes (already commited) and comments that need no action:

total: data.total,
pageCount: data.pageCount,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

a ? a : b -> a || b


export type PublicTrackerResponse<M extends D2ModelSchemaBase, Fields> = {
instances: SelectedPick<M, Fields>[];
interface ParamTracker extends TrackedPager {
pager: TrackedPager;
Copy link
Contributor

Choose a reason for hiding this comment

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

We set this prop as optional, that was the logic what motivated the a || b logic. And also pager?: TrackedPager in the 3 tracker responses from the api.

export interface TrackerEnrollmentsResponse<Fields> {
page: number;
pageSize: number;
export interface TrackerEnrollmentsResponse<Fields> extends TrackedPager {
Copy link
Contributor

Choose a reason for hiding this comment

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

To be struct, now we don't have always TrackedPager, in the future it will disappear. But since the logic to handle this is not trivial, let's leave as is, the runtime logic is correct.

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