diff --git a/releases/unreleased/improve-loading-time-when-looking-for-organizations.yml b/releases/unreleased/improve-loading-time-when-looking-for-organizations.yml new file mode 100644 index 00000000..45859177 --- /dev/null +++ b/releases/unreleased/improve-loading-time-when-looking-for-organizations.yml @@ -0,0 +1,9 @@ +--- +title: Improved loading time when looking for organizations +category: added +author: Eva Millán +issue: null +notes: > + The autocomplete field that is used to affiliate individuals + to organizations now makes fewer and lighter requests to find + them, resulting in faster loading times. diff --git a/ui/src/apollo/queries.js b/ui/src/apollo/queries.js index db33e030..c6bc09d4 100644 --- a/ui/src/apollo/queries.js +++ b/ui/src/apollo/queries.js @@ -277,6 +277,21 @@ const GET_SCHEDULED_TASKS = gql` } `; +const FIND_ORGANIZATION = gql` + query findOrganization( + $page: Int + $pageSize: Int + $filters: OrganizationFilterType + ) { + organizations(page: $page, pageSize: $pageSize, filters: $filters) { + entities { + id + name + } + } + } +`; + const getIndividualByUuid = (apollo, uuid) => { let response = apollo.query({ query: GET_INDIVIDUAL_BYUUID, @@ -445,6 +460,17 @@ const getScheduledTasks = (apollo, jobType, backend) => { }); }; +const findOrganization = (apollo, page, pageSize, filters) => { + return apollo.query({ + query: FIND_ORGANIZATION, + variables: { + page, + pageSize, + filters, + }, + }); +}; + export { getCountries, getIndividuals, @@ -460,4 +486,5 @@ export { getImportIdentitiesTasks, getOrganization, getScheduledTasks, + findOrganization, }; diff --git a/ui/src/views/Individual.vue b/ui/src/views/Individual.vue index f4ac96d8..4d85070f 100644 --- a/ui/src/views/Individual.vue +++ b/ui/src/views/Individual.vue @@ -410,7 +410,7 @@ import { getCountries, getIndividualByUuid, - getPaginatedOrganizations, + findOrganization, } from "../apollo/queries"; import { deleteIdentity, @@ -682,7 +682,7 @@ export default { this.individual = formatIndividual(newData[0]); }, async fetchOrganizations(page, items, filters) { - const response = await getPaginatedOrganizations( + const response = await findOrganization( this.$apollo, page, items,