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

fix: [DHIS2-15814] missing orgunit names #3449

Merged
merged 15 commits into from
Nov 10, 2023
Merged

fix: [DHIS2-15814] missing orgunit names #3449

merged 15 commits into from
Nov 10, 2023

Conversation

superskip
Copy link
Contributor

@superskip superskip commented Oct 27, 2023

DHIS2-15814

This should fix all the currently consistently failing cypress tests!

@superskip superskip requested a review from a team as a code owner October 27, 2023 12:18
@github-actions
Copy link

github-actions bot commented Oct 30, 2023

@@ -3,7 +3,7 @@ import React from 'react';
import { errorCreator } from 'capture-core-utils';
import log from 'loglevel';
import { WidgetEnrollment as WidgetEnrollmentComponent } from './WidgetEnrollment.component';
import { useOrganizationUnit } from './hooks/useOrganizationUnit';
import { useOrgUnitName } from '../../metadataRetrieval/orgUnitName';
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO the self-contained WidgetEnrollment should not rely on external cached metadata and it should have its own logic to retrieve the orgUnitName. Can we make the widget pull its own metadata? WDYT?

Copy link
Contributor Author

@superskip superskip Oct 31, 2023

Choose a reason for hiding this comment

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

I think @JoakimSM was of the opinion that the file which useOrgUnitName comes from can be made into a proper dependency. (I.e. a dependency of the sort that one puts into package.json.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Moving useOrgUnitName to a package dependency sounds good to me (perhaps it can be one of the hooks provided by the app runtime library 🤔). To be able to follow up on this, can you create a TECH issue and link it to this ticket? Thank you!

@@ -2,6 +2,7 @@
import { useMemo } from 'react';
import { convertValue } from '../../../../converters/serverToClient';
import { dataElementTypes } from '../../../../metaData';
import { useOrgUnitNames } from '../../../../metadataRetrieval/orgUnitName';
Copy link
Contributor

Choose a reason for hiding this comment

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

Same concerns here about adding a dependency to the self-contained WidgetProfile on external metadata.

[setFetching, setError],
);

const { refetch } = useDataQuery(
Copy link
Contributor

Choose a reason for hiding this comment

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

The ticket description mentions using react-query, what was the reason behind using the app-runtime hook instead? Thanks!

Copy link
Contributor Author

@superskip superskip Oct 31, 2023

Choose a reason for hiding this comment

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

I had a look at react-query, but came to the conclusion that it wasn't the right tool for the job; for one it caches by default based on all parameters in a request. In the case of working lists we want to fetch several names in a single request and cache each name separately. According to @eirikhaugstulen it should be possible to set up react-query so that it caches this way, but it implies having to battle with the system. Secondly I got the impression that one of the main merits with using react-query is the built-in memory management system, with stale times and automatic garbage collection. In the case of translated orgunit names we agreed there was no reason to expect changes during a single session. Thinking about it now it could be used for saving a little memory though, but hardly noticeable most likely.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! Thanks for the explanation 😄

@superskip superskip added testing and removed testing labels Oct 31, 2023
@superskip superskip added testing and removed testing labels Nov 2, 2023
Copy link

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

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

Tested successfully on 2.41,2.40.2,2.39.4,2.38.6 versions

Copy link
Member

@JoakimSM JoakimSM left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@superskip superskip removed the testing label Nov 9, 2023
@superskip superskip added testing and removed testing labels Nov 10, 2023
@superskip superskip merged commit 488f8c0 into master Nov 10, 2023
69 of 75 checks passed
@superskip superskip deleted the DHIS2-15814 branch November 10, 2023 16:33
dhis2-bot added a commit that referenced this pull request Nov 10, 2023
## [100.44.3](v100.44.2...v100.44.3) (2023-11-10)

### Bug Fixes

* [DHIS2-15814] missing orgunit names ([#3449](#3449)) ([488f8c0](488f8c0))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.44.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants