Filter user workspaces by projectId and actualState
What does this MR do and why?
Filter user workspaces by projectId and actualState
Add two parameters to the GraphQL workspaces API that enable the following filtering capabilities:
- Workspaces that match a project id
- Workspaces that does not match an actualState
Motivation
I’m working on displaying a user’s workspaces for a given project. The workspaces will appear in a dropdown group inside the "Edit" dropdown button in the Repository view. The space is constrained therefore we want to avoid displaying terminated workspaces in this context.
Query plans
These are the database queries I’ve along with its query plans:
by_project_id
SELECT
"workspaces".*
FROM
"workspaces"
WHERE
"workspaces"."user_id" = 1
AND "workspaces"."project_id" = 3
ORDER BY
"workspaces"."id" DESC;
query plan: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19652/commands/64252
with_actual_states
SELECT
"workspaces".*
FROM
"workspaces"
WHERE
"workspaces"."user_id" = 1
AND "workspaces"."actual_state" = 'Terminated'
ORDER BY
"workspaces"."id" DESC;
Query plan: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19652/commands/64253
Screenshots or screen recordings
This Merge Request doesn’t contain UI changes.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Prerequisites
- You should have a valid EE License in your local environment
- Enable the
remote_development_feature_flag
feature flag. - Set up remote development in your local environment and create one or more Workspaces.
Testing
Run the following query in http://gdk.test:3000/-/graphql-explorer
{
currentUser {
workspaces(projectIds: ["gid://gitlab/Project/3"], includeActualStates: ["Terminated"]) {
nodes {
id
actualState
}
}
}
}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #415126 (closed) and #415230 (closed)