Skip to content

Commit

Permalink
Merge branch 'ui-orgs-performance' of 'https://github.com/jjmerchante…
Browse files Browse the repository at this point in the history
  • Loading branch information
sduenas authored Dec 26, 2023
2 parents 06d9615 + 6c28d38 commit 7a33fbe
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 63 deletions.
8 changes: 8 additions & 0 deletions releases/unreleased/performance-of-organizations-query.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Performance of organizations query
category: performance
author: Jose Javier Merchante <[email protected]>
issue: null
notes: >
Improve organization query for the table by avoiding individual
queries.
3 changes: 0 additions & 3 deletions ui/src/apollo/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ const GET_PAGINATED_ORGANIZATIONS = gql`
name
enrollments {
id
individual {
mk
}
}
domains {
domain
Expand Down
50 changes: 25 additions & 25 deletions ui/src/components/ExpandedOrganization.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ export const Default = () => ({
name: "Committee on Experimental Charms",
numchild: 0,
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 5, individual: { mk: 5 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
],
},
{
name: "Department of Magical Law Enforcement",
numchild: 2,
enrollments: [{ id: 1, individual: { mk: 1 } }],
enrollments: [{ id: 1}],
},
{
name: "Department of Magical Accidents and Catastrophes",
Expand All @@ -51,32 +51,32 @@ export const Default = () => ({
name: "Department for the Regulation and Control of Magical Creatures",
numchild: 1,
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
],
},
{
name: "Auror Office",
parent: "Department of Magical Law Enforcement",
numchild: 0,
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 5, individual: { mk: 5 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
],
},
{
name: "Improper Use of Magic Office",
parent: "Department of Magical Law Enforcement",
numchild: 0,
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
],
},
{
Expand All @@ -85,8 +85,8 @@ export const Default = () => ({
"Department for the Regulation and Control of Magical Creatures",
numchild: 0,
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 1 },
{ id: 2 },
],
},
],
Expand Down Expand Up @@ -153,11 +153,11 @@ export const Group = () => ({
name: "Witches' League",
numchild: 0,
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 5, individual: { mk: 5 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
],
},
],
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/ExpandedOrganization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default {
return 0;
}
const uniqueIndividuals = new Set(

Check warning on line 164 in ui/src/components/ExpandedOrganization.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.8

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`

Check warning on line 164 in ui/src/components/ExpandedOrganization.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.8

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`

Check warning on line 164 in ui/src/components/ExpandedOrganization.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.9

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`

Check warning on line 164 in ui/src/components/ExpandedOrganization.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.9

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`
enrollments.map((item) => item.individual.mk)
enrollments.map((item) => item.id)
);
return uniqueIndividuals.size;
Expand Down
66 changes: 33 additions & 33 deletions ui/src/components/OrganizationsTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@ export const Organizations = () => ({
id: 1,
name: "Griffyndor",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 5, individual: { mk: 5 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
],
domains: [{ domain: "griffyndor.hogwarts.edu" }],
},
{
id: 2,
name: "Slytherin",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 1 },
{ id: 2 },
],
domains: [{ domain: "slytherin.hogwarts.edu" }],
},
{
id: 3,
name: "Ravenclaw",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
],
domains: [{ domain: "ravenclaw.hogwarts.edu" }],
},
Expand All @@ -143,10 +143,10 @@ export const Organizations = () => ({
id: 4,
name: "Hufflepuff",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
],
domains: [{ domain: "hufflepuff.hogwarts.edu" }],
},
Expand Down Expand Up @@ -243,28 +243,28 @@ export const Groups = () => ({
id: 1,
name: "Dark Force Defence League",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 5, individual: { mk: 5 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
],
},
{
id: 2,
name: "Extraordinary Society of Potioneers",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 1 },
{ id: 2 },
],
},
{
id: 3,
name: "Society for the Tolerance of Vampires",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
],
},
],
Expand All @@ -285,27 +285,27 @@ export const Groups = () => ({
id: 4,
name: "Frog Choir",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 4, individual: { mk: 4 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
],
},
{
id: 5,
name: "Celestial Ball decorating committee",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 3, individual: { mk: 3 } },
{ id: 1 },
{ id: 2 },
{ id: 3 },
],
},
{
id: 6,
name: "Duelling Club",
enrollments: [
{ id: 1, individual: { mk: 1 } },
{ id: 2, individual: { mk: 2 } },
{ id: 1 },
{ id: 2 },
],
},
],
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/OrganizationsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export default {
return 0;
}
const uniqueIndividuals = new Set(

Check warning on line 461 in ui/src/components/OrganizationsTable.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.8

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`

Check warning on line 461 in ui/src/components/OrganizationsTable.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.8

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`

Check warning on line 461 in ui/src/components/OrganizationsTable.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.9

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`

Check warning on line 461 in ui/src/components/OrganizationsTable.vue

View workflow job for this annotation

GitHub Actions / Node 16.x Python 3.9

Replace `⏎········enrollments.map((item)·=>·item.id)⏎······` with `enrollments.map((item)·=>·item.id)`
enrollments.map((item) => item.individual.mk)
enrollments.map((item) => item.id)
);
return uniqueIndividuals.size;
Expand Down

0 comments on commit 7a33fbe

Please sign in to comment.