Repository navigation
Optimize peer-review team membership lookups - #112
Conversation
rafecolton
left a comment
There was a problem hiding this comment.
Good optimization 👍
Couple notes:
- Do we still need pagination now that we're expecting to return only 0 or 1 result per team?
- It's possible search multiple teams in much the same way as multiple members, so I'm wondering if we should optimize that too and do the whole thing in a single query:
{
organization(login: "Expensify") {
expensify: team(slug: "expensify-expensify") {
rafecolton: members(query: "rafecolton") {
nodes {
login
}
}
roryabraham: members(query: "roryabraham") {
nodes {
login
}
}
chrispader: members(query: "chrispader") {
nodes {
login
}
}
}
margelo: team(slug: "margelo") {
rafecolton: members(query: "rafecolton") {
nodes {
login
}
}
roryabraham: members(query: "roryabraham") {
nodes {
login
}
}
chrispader: members(query: "chrispader") {
nodes {
login
}
}
}
}
}Produces this:
{
"data": {
"organization": {
"expensify": {
"rafecolton": {
"nodes": [
{
"login": "rafecolton"
}
]
},
"roryabraham": {
"nodes": [
{
"login": "roryabraham"
}
]
},
"chrispader": {
"nodes": []
}
},
"margelo": {
"rafecolton": {
"nodes": []
},
"roryabraham": {
"nodes": []
},
"chrispader": {
"nodes": [
{
"login": "chrispader"
}
]
}
}
}
}
}|
Both good suggestions! We could definitely drop pagination for our current use-cases, I seriously considered it and probably should have. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 944a4519ae
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
rafecolton
left a comment
There was a problem hiding this comment.
I find that the more a query is broken up and parameterized, the harder it is to see what the final query is and to test & maintain it. It would be helpful to at least add comments above each block and the final query showing examples. In this case, since there's not really an opportunity for user-provided values to be a problem, I think you could inline almost everything
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@rafecolton this is ready for another review. I agree it's simpler and better after your suggestions. |
| const memberQueries = uniqueCandidateLogins.map((login, i) => `member${i}: members(first: 1, query: ${JSON.stringify(login)}) { nodes { login } }`).join('\n'); | ||
| const teamQueries = uniqueTeamSlugs.map((slug, i) => `team${i}: team(slug: ${JSON.stringify(slug)}) {\n${memberQueries}\n}`).join('\n'); | ||
| const response = await client.graphql<TeamMembersResponse>(`{\norganization(login: "${EXPENSIFY_ORG}") {\n${teamQueries}\n}\n}`); |
There was a problem hiding this comment.
NAB graphql doesn't require or are about newlines, so they are only useful if you're trying to print a human-readable version.
Details
Avoids downloading the entire team roster (2 graphQL queries, the first with 100 nodes), just to determine whether a few independent approvers are eligible reviewers.
Pass only independent approver logins to
getTeamMemberLoginsand batch theirmembers(query: ...)searches using GraphQL in one request per eligible team.Related Issues
For https://github.com/Expensify/Expensify/issues/670058#issuecomment-5720068070 (point 2)
Manual Tests
Linked PRs
None.