Skip to content

Commit eefe0a3

Browse files
authored
perf(webapp): bound environment loads in the env layout and batches list (#4606)
## Summary Follow-up to #4595. Dashboard pages under an environment loaded every environment in the project on each page just to resolve the one named in the URL. On projects with many preview branches that meant reading hundreds of (mostly archived) rows on every page load. ## Fix The environment-scoped layout loader now scopes its lookup to the slug in the URL (`where: { slug: envParam }`), resolving the current environment through the `projectId, slug` composite index instead of loading the whole project. Archived branches stay viewable by slug. `BatchListPresenter` is bounded to the current environment, since every batch in that list already belongs to it. Verified on a project seeded with 2,000 archived branch environments: the layout lookup drops from all environments to one, and both a normal environment page and an archived branch page render correctly.
1 parent 6685cbd commit eefe0a3

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: improvement
4+
---
5+
6+
Dashboard pages load faster on projects with many preview branches by no longer loading every environment on each page.

apps/webapp/app/presenters/v3/BatchListPresenter.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export class BatchListPresenter extends BasePresenter {
200200
select: {
201201
id: true,
202202
environments: {
203+
where: { id: environmentId },
203204
select: {
204205
id: true,
205206
type: true,

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam/route.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
4040
externalRef: true,
4141
organization: { select: { id: true, featureFlags: true } },
4242
environments: {
43+
where: { slug: envParam },
4344
select: {
4445
id: true,
4546
type: true,

0 commit comments

Comments
 (0)