import type { ServiceMethodFactory } from "@ethicdevs/react-monolith";
import type { PullRequest, Repository } from "@prisma/client";
import type {
PullRequestSelectOrIncludes,
PullRequestServiceDeps,
} from "./types";
const getPullRequestsInRepository: ServiceMethodFactory<
PullRequestServiceDeps,
[Repository, PullRequestSelectOrIncludes | undefined],
Promise<PullRequest[]>
> = ({ request }) => {
return async (repository, selectOrIncludes) => {
const pullRequestsInRepository = await request.prisma.pullRequest.findMany({
...(selectOrIncludes || {}),
where: {
targetRepositoryId: repository.id,
},
});
return pullRequestsInRepository;
};
};
export default getPullRequestsInRepository;