Create a Graphql Type for Pages Deployments on Namespace
What does this MR do and why?
This MR is part of #443641 (closed).
It introduces the GraphQL backend to query all Pages deployments within a namespace.
The project namespace query is not needed initially and will be introduced by a later MR, in order to keep this MR within a manageable size.
How to set up and validate locally
- Make sure both Pages and Runners are enabled and set up in your GDK.
- Create or open a group.
- In that group, create multiple new Pages projects, for example by cloning the "Plain HTML Page" template.
- In each project, run the pipeline to create a pages deployment. Feel free to run it multiple times.
- Perform steps 2-4 within your user namespace, too.
- Run the below Graphql Query:
query GetNamespacePagesDeployments {
namespace(fullPath: "<FULL_PATH_TO_THE_NAMESPACE>") {
id
name
pagesDeployments(<FILTERS>) {
count
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
edges {
node {
id
project {
id
name
}
active
ciBuildId
createdAt
deletedAt
fileCount
pathPrefix
rootDirectory
size
updatedAt
url
}
}
}
}
}
- Verify all expected pages deployments are returned.
Database
Raw Query
Below is a query if all filters and sort options are set.
All possible filters set
SELECT "pages_deployments".*
FROM "pages_deployments"
WHERE "pages_deployments"."project_id" IN (
SELECT "projects"."id"
FROM "projects"
WHERE "projects"."namespace_id" = 9970
)
AND "pages_deployments"."upload_ready" = TRUE
AND "pages_deployments"."deleted_at" IS NULL
AND ("pages_deployments"."path_prefix" = '' OR "pages_deployments"."path_prefix" IS NULL)
ORDER BY "pages_deployments"."updated_at" DESC
Query Plan
Sort (cost=90.33..90.33 rows=1 width=214) (actual time=1.544..1.546 rows=27 loops=1)
Sort Key: pages_deployments.updated_at DESC
Sort Method: quicksort Memory: 32kB
Buffers: shared hit=1309
I/O Timings: read=0.000 write=0.000
-> Nested Loop (cost=0.99..90.32 rows=1 width=214) (actual time=0.143..1.487 rows=27 loops=1)
Buffers: shared hit=1306
I/O Timings: read=0.000 write=0.000
-> Index Only Scan using index_projects_on_namespace_id_and_id on public.projects (cost=0.56..4.00 rows=25 width=4) (actual time=0.040..0.265 rows=288 loops=1)
Index Cond: (projects.namespace_id = 9970)
Heap Fetches: 40
Buffers: shared hit=322
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_pages_deployments_on_project_id on public.pages_deployments (cost=0.42..3.44 rows=1 width=214) (actual time=0.004..0.004 rows=0 loops=288)
Index Cond: (pages_deployments.project_id = projects.id)
Filter: (pages_deployments.upload_ready AND (pages_deployments.deleted_at IS NULL) AND ((pages_deployments.path_prefix = ''::text) OR (pages_deployments.path_prefix IS NULL)))
Rows Removed by Filter: 0
Buffers: shared hit=984
I/O Timings: read=0.000 write=0.000
Related to #456095 (closed)
Edited by Janis Altherr