Don’t count internal or other project jobs in the integration table
This commit is contained in:
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
+11
-4
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user