update JobPresenter query to use findFirst.
This commit is contained in:
@@ -12,15 +12,31 @@ export class JobsListPresenter {
|
||||
public async call({
|
||||
slug,
|
||||
userId,
|
||||
}: {
|
||||
slug: string;
|
||||
userId: string;
|
||||
}): Promise<Job[]> {
|
||||
return this.#prismaClient.job.findMany({
|
||||
}: Pick<Job, "slug"> & { userId: User["id"] }) {
|
||||
const project = await this.#prismaClient.project.findFirst({
|
||||
where: {
|
||||
projectId: slug,
|
||||
id: userId,
|
||||
slug,
|
||||
organization: {
|
||||
members: {
|
||||
some: {
|
||||
userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
jobs: {
|
||||
where: {
|
||||
internal: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!project) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return project.jobs.filter((job) => !job.internal);
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -38,7 +38,6 @@ export const loader = async ({ request, params }: LoaderArgs) => {
|
||||
const { projectParam } = params;
|
||||
const userId = await requireUserId(request);
|
||||
invariant(projectParam, "projectParam not found");
|
||||
invariant(userId, "jobId not found");
|
||||
|
||||
try {
|
||||
const jobsPresenter = new JobsListPresenter();
|
||||
|
||||
Reference in New Issue
Block a user