GraphQl Query to list selfManagedUsersQueuedForRolePromotion for admin
What does this MR do and why?
- This MR adds graphql query capability to get MemberApproval objects corresponding to the highest new_access_level, for each user.
- Adds the Scope, Finder, Resolver, Type, QueryType for the above
EE: true Changelog: added
ref: #433175 (closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
-
Navigate to http://localhost:3000/-/graphql-explorer (ensure you have queued pending promotion members)
-
Query
{ selfManagedUsersQueuedForRolePromotion(first:3, after:"<some_end_cursor>") { count nodes { user { id username } newAccessLevel { stringValue } } pageInfo { hasNextPage hasPreviousPage startCursor endCursor } } }
-
-
Validate sample response
{ "data": { "selfManagedUsersQueuedForRolePromotion": { "count": 13 "nodes": [ { "user": { "id": "gid://gitlab/User/3", "username": "annamae.johns" }, "newAccessLevel": { "stringValue": "DEVELOPER" } }, { "user": { "id": "gid://gitlab/User/4", "username": "marva_schoen" }, "newAccessLevel": { "stringValue": "DEVELOPER" } }, { "user": { "id": "gid://gitlab/User/5", "username": "theressa.gislason" }, "newAccessLevel": { "stringValue": "DEVELOPER" } } ], "pageInfo": { "hasNextPage": true, "hasPreviousPage": true, "startCursor": "eyJ1c2VyX2lkIjoiMyIsIm5ld19hY2Nlc3NfbGV2ZWwiOiIzMCIsImlkIjoiNDkifQ", "endCursor": "eyJ1c2VyX2lkIjoiNSIsIm5ld19hY2Nlc3NfbGV2ZWwiOiIzMCIsImlkIjoiNjEifQ" } } } }
Database
Since the table is empty on production, I added ~450 records on my local db and am sharing the Explain plan from those
Query 1
for scope pending_member_approvals_with_max_new_access_level
Link for Explain: https://explain.depesz.com/s/PXC6#html
SELECT DISTINCT ON (user_id) * FROM "member_approvals" WHERE "member_approvals"."status" = 0 ORDER BY "member_approvals"."user_id" ASC, "member_approvals"."new_access_level" DESC, "member_approvals"."created_at" ASC, "member_approvals"."id" DESC LIMIT 21
Query 2
SELECT COUNT(*) FROM (SELECT DISTINCT ON (user_id) * FROM "member_approvals" WHERE "member_approvals"."status" = 0)
Link for Explain plan: https://explain.depesz.com/s/0yf1