Skip to content

Commit

Permalink
chore(admin,api): remove getCompanionsForCandidacy
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricss committed Jul 4, 2024
1 parent dd6384c commit a146bc5
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 222 deletions.
12 changes: 0 additions & 12 deletions packages/reva-admin/graphql/elm/Admin/Query.elm
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,6 @@ getRandomOrganismsForCandidacy fillInOptionals____ requiredArgs____ object____ =
Object.selectionForCompositeField "getRandomOrganismsForCandidacy" (optionalArgs____ ++ [ Argument.required "candidacyId" requiredArgs____.candidacyId (Data.Scalar.codecs |> Admin.Scalar.unwrapEncoder .codecUuid) ]) object____ Basics.identity


type alias GetCompanionsForCandidacyRequiredArguments =
{ candidacyId : Data.Scalar.Uuid }


getCompanionsForCandidacy :
GetCompanionsForCandidacyRequiredArguments
-> SelectionSet decodesTo Admin.Object.Organism
-> SelectionSet (List decodesTo) RootQuery
getCompanionsForCandidacy requiredArgs____ object____ =
Object.selectionForCompositeField "getCompanionsForCandidacy" [ Argument.required "candidacyId" requiredArgs____.candidacyId (Data.Scalar.codecs |> Admin.Scalar.unwrapEncoder .codecUuid) ] object____ (Basics.identity >> Decode.list)


getBasicSkills :
SelectionSet decodesTo Admin.Object.BasicSkill
-> SelectionSet (List decodesTo) RootQuery
Expand Down
9 changes: 2 additions & 7 deletions packages/reva-admin/src/Api/Candidacy.elm
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ selection id =
candidacyRequiredArgs =
Query.GetCandidacyByIdRequiredArguments (Id id)

getCompanionsRequiredArg =
Query.GetCompanionsForCandidacyRequiredArguments (Uuid id)

getCandidacyMenuRequiredArg =
Query.CandidacyMenuGetCandidacyMenuRequiredArguments (Id id)

Expand All @@ -158,7 +155,6 @@ selection id =
candidacySelectionWithoutCompanionsAndCandidacyMenu =
SelectionSet.succeed Data.Candidacy.Candidacy
|> with (SelectionSet.map (\(Id candidacyId) -> Data.Candidacy.candidacyIdFromString candidacyId) Admin.Object.Candidacy.id)
|> with (SelectionSet.succeed [])
|> with (Admin.Object.Candidacy.candidate candidateSelection)
|> with (SelectionSet.map (Maybe.map (\(Id certificationId) -> certificationId)) Admin.Object.Candidacy.certificationId)
|> with (Admin.Object.Candidacy.organism Organism.selection)
Expand All @@ -184,12 +180,11 @@ selection id =
|> with (SelectionSet.succeed (Data.Candidacy.CandidacyMenu [] [] []))
in
SelectionSet.succeed
(\maybeCandidacy companions candidacyMenu ->
(\maybeCandidacy candidacyMenu ->
maybeCandidacy
|> Maybe.map (\candidacy -> { candidacy | availableCompanions = companions, candidacyMenu = candidacyMenu })
|> Maybe.map (\candidacy -> { candidacy | candidacyMenu = candidacyMenu })
)
|> with (Query.getCandidacyById candidacyRequiredArgs candidacySelectionWithoutCompanionsAndCandidacyMenu)
|> with (Query.getCompanionsForCandidacy getCompanionsRequiredArg Organism.selection)
|> with (Query.candidacyMenu_getCandidacyMenu getCandidacyMenuRequiredArg getCandidacyMenuSelection)


Expand Down
1 change: 0 additions & 1 deletion packages/reva-admin/src/Data/Candidacy.elm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ type alias CandidacyExperience =

type alias Candidacy =
{ id : CandidacyId
, availableCompanions : List Organism
, candidate : Maybe Candidate
, certificationId : Maybe String
, organism : Maybe Organism
Expand Down
9 changes: 0 additions & 9 deletions packages/reva-admin/src/Page/Form/PaymentRequestUniReva.elm
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ keys =
form : Maybe Certification -> FormData -> ( Candidacy, Referential ) -> Form
form maybeCertification formData ( candidacy, referential ) =
let
availableCompanions : List ( String, String )
availableCompanions =
candidacy.availableCompanions
|> Data.Form.Helper.toIdList

estimatedCostElement : Form.Element
estimatedCostElement =
Form.Number "Coût horaire prévu"
Expand Down Expand Up @@ -85,10 +80,6 @@ form maybeCertification formData ( candidacy, referential ) =
, ( keys.postExamHourCount, hourCountElement )
, ( keys.postExamCost, costElement )
, ( "companion", Form.Title2 "Accompagnement" )
, ( keys.companionId
, Form.ReadOnlyElement <|
Form.Select "Accompagnateur choisi par le candidat" availableCompanions
)
, ( "individual", Form.TitleInlined "Individuel" )
, ( "individualReview"
, Form.ReadOnlyElements
Expand Down
1 change: 0 additions & 1 deletion packages/reva-api/modules/candidacy/candidacy.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ type Query {
searchText: String
searchFilter: SearchOrganismFilter
): RamdomOrganisms!
getCompanionsForCandidacy(candidacyId: UUID!): [Organism!]!
getBasicSkills: [BasicSkill!]!
candidacy_candidacyCountByStatus(
searchFilter: String
Expand Down
30 changes: 0 additions & 30 deletions packages/reva-api/modules/candidacy/candidacy.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ import { getCandidacyCountByStatus } from "./features/getCandidacyCountByStatus"
import { getCandidacyGoals } from "./features/getCandidacyGoals";
import { getCandidacyWithActiveCertificationByCandidacyId } from "./features/getCandidacyWithActiveCertificationByCandidacyId";
import { getCandidateByCandidacyId } from "./features/getCandidateByCandidacyId";
import { getCompanionsForCandidacy } from "./features/getCompanionsForCandidacy";
import { getExperiencesByCandidacyId } from "./features/getExperiencesByCandidacyId";
import { getMandatoryTrainingsByCandidacyId } from "./features/getMandatoryTrainingsByCandidacyId ";
import { getActiveOrganismsForCandidacyWithNewTypologies } from "./features/getOrganismsForCandidacy";
import { getRandomOrganismsForCandidacyWithNewTypologies } from "./features/getRandomOrganismsForCandidacy";
import { getTrainings } from "./features/getTrainings";
import { searchOrganismsForCandidacy } from "./features/searchOrganismsForCandidacy";
Expand Down Expand Up @@ -270,34 +268,6 @@ const unsafeResolvers = {

return result.extract();
},
getCompanionsForCandidacy: async (
_: unknown,
params: { candidacyId: string },
) => {
const candidacy = await prismaClient.candidacy.findUnique({
where: { id: params.candidacyId },
include: { organism: true },
});
if (candidacy) {
//companion organisms are fetched differently if the candidacy organism typology is "experimentation" or not
const result = await (candidacy.organism?.typology === "experimentation"
? getCompanionsForCandidacy({
getCompanionsForCandidacy: organismDb.getCompanionOrganisms,
})({ candidacyId: params.candidacyId })
: getActiveOrganismsForCandidacyWithNewTypologies({
getActiveOrganismForCertificationAndDepartment:
organismDb.getActiveOrganismForCertificationAndDepartment,
getCandidacyFromId: candidacyDb.getCandidacyFromId,
})({ candidacyId: params.candidacyId }));

return result
.mapLeft(
(error) => new mercurius.ErrorWithProps(error.message, error),
)
.extract();
}
return [];
},
candidacy_candidacyCountByStatus: (
_: unknown,
_params: {
Expand Down

This file was deleted.

This file was deleted.

95 changes: 0 additions & 95 deletions packages/reva-api/modules/organism/database/organisms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import * as domain from "../organism.types";
import { getFeatureByKey } from "../../feature-flipping/feature-flipping.features";
import { getLastProfessionalCgu } from "../features/getLastProfessionalCgu";

export const getAAPOrganisms = async (params: {
candidacyId: string;
}): Promise<Either<string, domain.Organism[]>> => {
return getOrganisms({ candidacyId: params.candidacyId, isArchitect: true });
};

export const getOrganismById = async (
organismId: string,
): Promise<Either<string, Maybe<domain.Organism>>> => {
Expand All @@ -33,69 +27,6 @@ export const getOrganismById = async (
}
};

export const getCompanionOrganisms = async (params: {
candidacyId: string;
}): Promise<Either<string, domain.Organism[]>> => {
return getOrganisms({ candidacyId: params.candidacyId, isCompanion: true });
};

const getOrganisms = async (params: {
candidacyId: string;
isArchitect?: boolean;
isCompanion?: boolean;
}) => {
try {
const candidacy = await prismaClient.candidacy.findFirst({
where: {
id: params.candidacyId,
certificationsAndRegions: { some: {} },
},
include: {
certificationsAndRegions: {
where: {
isActive: true,
},
select: {
certificationId: true,
regionId: true,
},
},
},
});

if (!candidacy) {
return Right([]);
}

let filters = {
certificationId: candidacy.certificationsAndRegions[0].certificationId,
regionId: candidacy.certificationsAndRegions[0].regionId,
} as Prisma.OrganismsOnRegionsAndCertificationsWhereInput;

if (params.isArchitect !== undefined) {
filters = { ...filters, isArchitect: params.isArchitect };
}

if (params.isCompanion !== undefined) {
filters = { ...filters, isCompanion: params.isCompanion };
}

const organisms = await prismaClient.organism.findMany({
where: {
regionsAndCertifications: {
some: filters,
},
isActive: true,
},
});

return Right(organisms);
} catch (e) {
logger.error(e);
return Left(`error while retrieving organisms`);
}
};

export const getOrganismBySiretAndTypology = async (
siret: string,
typology: OrganismTypology,
Expand Down Expand Up @@ -177,32 +108,6 @@ export const createOrganism = async (data: {
}
};

export const getActiveOrganismForCertificationAndDepartment = async ({
certificationId,
departmentId,
}: {
certificationId: string;
departmentId: string;
}): Promise<Either<string, domain.Organism[]>> => {
try {
if (!certificationId || !departmentId) {
return Right([]);
}
return Right(
await prismaClient.organism.findMany({
where: {
activeOrganismsByAvailableCertificationsAndDepartments: {
some: { AND: [{ certificationId }, { departmentId }] },
},
},
}),
);
} catch (e) {
logger.error(e);
return Left(`error while retreiving organism`);
}
};

export const getReferentOrganismFromCandidacyId = async (
candidacyId: string,
) => {
Expand Down

0 comments on commit a146bc5

Please sign in to comment.