Skip to content

Commit

Permalink
feat(api): added a new getCompetenceBlocsByCertificationV2 method and…
Browse files Browse the repository at this point in the history
… added it to the Certification->competenceBlocs resolver when the ANNUAIRE_CERTIFICATIONS_V2 feature is active
  • Loading branch information
agarbe committed Nov 14, 2024
1 parent b973b9e commit 29e55a9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { prismaClient } from "../../../prisma/client";

export const getCompetenceBlocsByCertificationIdV2 = async ({
certificationId,
}: {
certificationId: string;
}) =>
prismaClient.certificationCompetenceBloc.findMany({
where: {
certificationId,
},
orderBy: [{ code: "asc" }, { label: "asc" }],
});
26 changes: 19 additions & 7 deletions packages/reva-api/modules/referential/referential.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import { getCertificationCompetenceBlocById } from "./features/getCertificationC
import { updateCertificationCompetenceBloc } from "./features/updateCertificationCompetenceBloc";
import { addCertification } from "./features/addCertification";
import { deleteCertificationCompetenceBloc } from "./features/deleteCertificationCompetenceBloc";
import { isFeatureActiveForUser } from "../feature-flipping/feature-flipping.features";
import { getCompetenceBlocsByCertificationIdV2 } from "./features/getCompetenceBlocsByCertificationIdV2";

const unsafeReferentialResolvers = {
Certification: {
Expand All @@ -52,13 +54,23 @@ const unsafeReferentialResolvers = {
degree: ({ level }: { level: number }) => getDegreeByLevel({ level }),
conventionsCollectives: ({ id: certificationId }: { id: string }) =>
getConventionsCollectivesByCertificationId({ certificationId }),
competenceBlocs: ({
id: certificationId,
rncpId,
}: {
id: string;
rncpId: string;
}) => getCompetenceBlocsByCertificationId({ certificationId, rncpId }),
competenceBlocs: async (
{
id: certificationId,
rncpId,
}: {
id: string;
rncpId: string;
},
_payload: unknown,
{ auth: { userInfo } }: GraphqlContext,
) =>
(await isFeatureActiveForUser({
feature: "ANNUAIRE_CERTIFICATIONS_V2",
userKeycloakId: userInfo?.sub,
}))
? getCompetenceBlocsByCertificationIdV2({ certificationId })
: getCompetenceBlocsByCertificationId({ certificationId, rncpId }),
},
CertificationCompetenceBloc: {
competences: ({ id: certificationCompetenceBlocId }: { id: string }) =>
Expand Down

0 comments on commit 29e55a9

Please sign in to comment.