From feda01ab3b2bf5ff66e70c746f93cdf58eb5dfd6 Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Mon, 12 Jun 2023 16:28:42 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20count=20internal=20or=20other?= =?UTF-8?q?=20project=20jobs=20in=20the=20integration=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presenters/IntegrationsPresenter.server.ts | 14 +++++++++++++- .../route.tsx | 15 +++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/apps/webapp/app/presenters/IntegrationsPresenter.server.ts b/apps/webapp/app/presenters/IntegrationsPresenter.server.ts index bde5fbd1b..04a24c637 100644 --- a/apps/webapp/app/presenters/IntegrationsPresenter.server.ts +++ b/apps/webapp/app/presenters/IntegrationsPresenter.server.ts @@ -5,6 +5,7 @@ import { Organization, getOrganizationFromSlug, } from "~/models/organization.server"; +import { Project } from "~/models/project.server"; import { apiAuthenticationRepository } from "~/services/externalApis/apiAuthenticationRepository.server"; import { integrationCatalog } from "~/services/externalApis/integrationCatalog.server"; import { OAuthClientSchema } from "~/services/externalApis/types"; @@ -19,9 +20,11 @@ export class IntegrationsPresenter { public async call({ userId, + projectSlug, organizationSlug, }: { userId: User["id"]; + projectSlug: Project["slug"]; organizationSlug: Organization["slug"]; }) { const clients = await this.#prismaClient.apiConnectionClient.findMany({ @@ -43,7 +46,16 @@ export class IntegrationsPresenter { _count: { select: { connections: true, - jobIntegrations: true, + jobIntegrations: { + where: { + job: { + project: { + slug: projectSlug, + }, + internal: false, + }, + }, + }, }, }, }, diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx index ca725e260..1ea81d6b8 100644 --- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx +++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx @@ -47,15 +47,22 @@ import { IntegrationsPresenter } from "~/presenters/IntegrationsPresenter.server import { requireUser } from "~/services/session.server"; import { formatDateTime } from "~/utils"; import { Handle } from "~/utils/handle"; -import { docsPath, integrationClientPath } from "~/utils/pathBuilder"; +import { + ProjectParamSchema, + docsPath, + integrationClientPath, +} from "~/utils/pathBuilder"; export const loader = async ({ request, params }: LoaderArgs) => { const user = await requireUser(request); - const { organizationSlug } = params; - invariant(organizationSlug, "organizationSlug not found"); + const { organizationSlug, projectParam } = ProjectParamSchema.parse(params); const presenter = new IntegrationsPresenter(); - const data = await presenter.call({ userId: user.id, organizationSlug }); + const data = await presenter.call({ + userId: user.id, + organizationSlug, + projectSlug: projectParam, + }); return typedjson(data); };