Skip to content

Commit

Permalink
feat(api): added Organism -> isVisibleInCandidateSearchResults resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
agarbe committed Aug 30, 2024
1 parent 20c7f7f commit ef0f07d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { prismaClient } from "../../../prisma/client";

export const isOrganismVisibleInCandidateSearchResults = async ({
organismId,
}: {
organismId: string;
}) => {
const o = await prismaClient.organism.findUnique({
where: { id: organismId },
include: {
managedDegrees: true,
organismOnDomaine: true,
organismOnConventionCollective: true,
},
});

return (
o &&
o.isActive &&
(o.isOnSite || o.isRemote) &&
!o.fermePourAbsenceOuConges &&
o.managedDegrees.length &&
(o.organismOnDomaine.length || o.organismOnConventionCollective.length)
);
};
1 change: 1 addition & 0 deletions packages/reva-api/modules/organism/organism.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Organism {
isRemote: Boolean!
remoteZones: [RemoteZone!]!
isHeadAgency: Boolean!
isVisibleInCandidateSearchResults: Boolean!
}

type OrganismOnDegree {
Expand Down
5 changes: 5 additions & 0 deletions packages/reva-api/modules/organism/organism.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { getRemoteZonesByOrganismId } from "./features/getRemoteZonesByOrganismI
import { updateMaisonMereAccountSetup } from "./features/updateMaisonMereAccountSetup";
import { createOrganismAccount } from "./features/createOrganismAccount";
import { updateOrganismAccountAndOrganism } from "./features/updateOrganismAccountAndOrganism";
import { isOrganismVisibleInCandidateSearchResults } from "./features/isOrganismVisibleInCandidateSearchResults";

const unsafeResolvers = {
Account: {
Expand Down Expand Up @@ -103,6 +104,10 @@ const unsafeResolvers = {
organismId,
})
).map((r) => r.remoteZone),
isVisibleInCandidateSearchResults: async ({ id: organismId }: Organism) =>
await isOrganismVisibleInCandidateSearchResults({
organismId,
}),
},
OrganismOnDegree: {
degree: (organismOnDegree: { degreeId: string }) =>
Expand Down

0 comments on commit ef0f07d

Please sign in to comment.