-
Notifications
You must be signed in to change notification settings - Fork 2
Add all the options in /analytics/enrollments/query endpoint accordinng to documentation #172
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 all the options in /analytics/enrollments/query endpoint accordinng to documentation #172
Conversation
…ng to documentation
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
tokland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-line comments:
| page: number; | ||
| pageSize: number; | ||
| paging: boolean; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, so now we get .metaData.pager object, but we don't have types for the response, right? Is that something we want to implement at this point? (we would use conditional types, let me know if you have no experience with them)
src/api/analytics.ts
Outdated
| asc?: AscDescParameter; | ||
| desc?: AscDescParameter; | ||
| coordinatesOnly?: boolean; | ||
| headers?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string types are too unspecific. Docs "One or more headers name separated by comma". At the worst case, we can create an alias: "type HeadersSeparatedByCommas = string". Question: Are these headers known? (dx, dxname, pe, ...)
src/api/analytics.ts
Outdated
| return this.d2Api.get<AnalyticsResponse>( | ||
| `/analytics/enrollments/query/${programId}`, | ||
| options as AnalyticsOptions | ||
| options as Omit<GetEnrollmentsQueryOptions, "programId"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit confused as to why we needed to cast the options object, it seemed compatible with the type. Apparently, it comes from the early unpacking that extracts programId. So let's keep it simple: options: GetEnrollmentsQueryOptions and now the cast can be removed.
src/api/analytics.ts
Outdated
| auth: { type: "basic", username: "admin", password: "district" }, | ||
| }); | ||
|
|
||
| export async function test() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically we don't have unused functions in the code as usage demos, but it won't hurt. Hopefully one day we can add proper specs and move this there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad, these were the tests I used to check if the conditional was working properly, and I should not have uploaded them.
src/api/analytics.ts
Outdated
| enrollmentDate: "LAST_12_MONTHS,THIS_MONTH", | ||
| paging: true, | ||
| totalPages: true, | ||
| skipData: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't the conditional conditional for skipMeta, right? no problem, it should not be a typical use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to do it, but since it didn't do anything if you set skipMeta to true or false, I haven't implemented it because I don't know if it affects any other fields appart from removing metaData (which would be logical, but just in case)
📌 References
Issue: Closes https://app.clickup.com/t/8699yjr23
Documentation: https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-241/analytics.html#webapi_enrollment_analytics_query_parameters
📝 Implementation
📹 Screenshots/Screen capture
🔥 Notes to the tester
For example: to get total pages
For example: to filter by program status
For example: to get order by ouname asc