From 0f8f86d637fe097f745b3a48fc4dfb213b7eb3a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Soulas?= Date: Wed, 13 Nov 2024 11:43:22 +0100 Subject: [PATCH] chore: remove unused legacy admissibility code (but keep data) --- .../candidacy-log/candidacy-log.types.ts | 1 - .../features/getCandidacyLogMessage.ts | 2 - .../modules/candidacy/candidacy.graphql | 26 ------- .../modules/candidacy/candidacy.resolvers.ts | 19 ----- .../modules/candidacy/candidacy.types.ts | 14 +--- .../features/getAdmissibilityByCandidacyId.ts | 12 --- .../candidacy/features/updateAdmissibility.ts | 74 ------------------- .../modules/candidacy/security/security.ts | 3 - 8 files changed, 2 insertions(+), 149 deletions(-) delete mode 100644 packages/reva-api/modules/candidacy/features/getAdmissibilityByCandidacyId.ts delete mode 100644 packages/reva-api/modules/candidacy/features/updateAdmissibility.ts diff --git a/packages/reva-api/modules/candidacy-log/candidacy-log.types.ts b/packages/reva-api/modules/candidacy-log/candidacy-log.types.ts index 9ce4d19e7..5c69a9763 100644 --- a/packages/reva-api/modules/candidacy-log/candidacy-log.types.ts +++ b/packages/reva-api/modules/candidacy-log/candidacy-log.types.ts @@ -30,7 +30,6 @@ export type CandidacyLogEventTypeAndDetails = | "CANDIDACY_DROP_OUT_CANCELED" | "CANDIDACY_DROP_OUT_VALIDATED" | "ADMISSIBILITY_FVAE_UPDATED" - | "ADMISSIBILITY_UPDATED" | "FEASIBILITY_SENT" | "FEASIBILITY_VALIDATED" | "FEASIBILITY_REJECTED" diff --git a/packages/reva-api/modules/candidacy-log/features/getCandidacyLogMessage.ts b/packages/reva-api/modules/candidacy-log/features/getCandidacyLogMessage.ts index 4e0983112..9c52aa5ba 100644 --- a/packages/reva-api/modules/candidacy-log/features/getCandidacyLogMessage.ts +++ b/packages/reva-api/modules/candidacy-log/features/getCandidacyLogMessage.ts @@ -77,8 +77,6 @@ export const getCandidacyLogMessage = ({ return "Validation de l'abandon de la candidature."; case "CANDIDACY_DROP_OUT_CANCELED": return "Annulation de l'abandon de la candidature."; - case "ADMISSIBILITY_UPDATED": - return "Information de recevabilité modifiées."; case "READY_FOR_JURY_ESTIMATED_DATE_UPDATED": return `Date prévisionenelle de finalisation ou de dépôt du dossier de validation modifiée. Nouvelle date ${format( details.readyForJuryEstimatedAt, diff --git a/packages/reva-api/modules/candidacy/candidacy.graphql b/packages/reva-api/modules/candidacy/candidacy.graphql index eaaffcc0d..d091d0914 100644 --- a/packages/reva-api/modules/candidacy/candidacy.graphql +++ b/packages/reva-api/modules/candidacy/candidacy.graphql @@ -66,7 +66,6 @@ type Candidacy { candidacyStatuses: [CandidacyStatus!]! candidacyDropOut: CandidacyDropOut createdAt: Timestamp! - admissibility: Admissibility! reorientationReason: ReorientationReason financeModule: FinanceModule! feasibilityFormat: FeasibilityFormat! @@ -134,19 +133,6 @@ enum OrganismTypology { expertBrancheEtFiliere } -type Admissibility { - isCandidateAlreadyAdmissible: Boolean! - reportSentAt: Timestamp - certifierRespondedAt: Timestamp - responseAvailableToCandidateAt: Timestamp - status: AdmissibilityStatus -} - -enum AdmissibilityStatus { - ADMISSIBLE - NOT_ADMISSIBLE -} - type CandidacyCountByStatus { ACTIVE_HORS_ABANDON: Int! ABANDON: Int! @@ -267,14 +253,6 @@ input DropOutInput { otherReasonContent: String } -input AdmissibilityInput { - isCandidateAlreadyAdmissible: Boolean! - reportSentAt: Timestamp - certifierRespondedAt: Timestamp - responseAvailableToCandidateAt: Timestamp - status: AdmissibilityStatus -} - type Mutation { candidacy_submitCandidacy(candidacyId: ID!): Candidacy candidacy_addExperience( @@ -311,10 +289,6 @@ type Mutation { candidacy_dropOut(candidacyId: UUID!, dropOut: DropOutInput!): Candidacy! candidacy_validateDropOut(candidacyId: UUID!): Candidacy! candidacy_cancelDropOutById(candidacyId: UUID!): Candidacy! - candidacy_updateAdmissibility( - candidacyId: UUID! - admissibility: AdmissibilityInput! - ): Admissibility! candidacy_setReadyForJuryEstimatedAt( candidacyId: UUID! readyForJuryEstimatedAt: Timestamp! diff --git a/packages/reva-api/modules/candidacy/candidacy.resolvers.ts b/packages/reva-api/modules/candidacy/candidacy.resolvers.ts index 1d8d3fb92..81aae9f8a 100644 --- a/packages/reva-api/modules/candidacy/candidacy.resolvers.ts +++ b/packages/reva-api/modules/candidacy/candidacy.resolvers.ts @@ -12,7 +12,6 @@ import { } from "../shared/error/functionalError"; import { logger } from "../shared/logger"; import { - Admissibility, Candidacy, CandidacyBusinessEvent, CandidacyStatusFilter, @@ -23,7 +22,6 @@ import { addExperienceToCandidacy } from "./features/addExperienceToCandidacy"; import { archiveCandidacy } from "./features/archiveCandidacy"; import { cancelDropOutCandidacy } from "./features/cancelDropOutCandidacy"; import { dropOutCandidacy } from "./features/dropOutCandidacy"; -import { getAdmissibilityByCandidacyId } from "./features/getAdmissibilityByCandidacyId"; import { getCandidacy } from "./features/getCandidacy"; import { getCandidacyCcns } from "./features/getCandidacyCcns"; import { getCandidacyCountByStatus } from "./features/getCandidacyCountByStatus"; @@ -35,7 +33,6 @@ import { setReadyForJuryEstimatedAt } from "./features/setReadyForJuryEstimatedA import { submitCandidacy } from "./features/submitCandidacy"; import { takeOverCandidacy } from "./features/takeOverCandidacy"; import { unarchiveCandidacy } from "./features/unarchiveCandidacy"; -import { updateAdmissibility } from "./features/updateAdmissibility"; import { updateAppointmentInformations } from "./features/updateAppointmentInformations"; import { updateCandidacyTypologyAndCcn } from "./features/updateCandidacyTypologyAndCcn"; import { updateContactOfCandidacy } from "./features/updateContactOfCandidacy"; @@ -62,8 +59,6 @@ import { getCandidacyFinancingMethodById } from "./features/getCandidacyFinancin const unsafeResolvers = { Candidacy: { - admissibility: ({ id: candidacyId }: Candidacy) => - getAdmissibilityByCandidacyId({ candidacyId }), goals: async ({ id: candidacyId }: Candidacy) => getCandidacyGoals({ candidacyId }), experiences: async ({ id: candidacyId }: Candidacy) => @@ -555,20 +550,6 @@ const unsafeResolvers = { return result; }, - candidacy_updateAdmissibility: async ( - { - candidacyId, - admissibility, - }: { candidacyId: string; admissibility: Admissibility }, - context: GraphqlContext, - ) => - updateAdmissibility({ - candidacyId, - admissibility, - userKeycloakId: context.auth.userInfo?.sub, - userEmail: context.auth.userInfo?.email, - userRoles: context.auth.userInfo?.realm_access?.roles || [], - }), candidacy_setReadyForJuryEstimatedAt: async ( _parent: unknown, params: { diff --git a/packages/reva-api/modules/candidacy/candidacy.types.ts b/packages/reva-api/modules/candidacy/candidacy.types.ts index be703fc1b..65c044628 100644 --- a/packages/reva-api/modules/candidacy/candidacy.types.ts +++ b/packages/reva-api/modules/candidacy/candidacy.types.ts @@ -4,6 +4,7 @@ export interface CandidacyDropOut { status: CandidacyStatusStep; otherReasonContent?: string | null; } + export interface Candidacy { id: string; isCertificationPartial?: boolean | null; @@ -29,17 +30,6 @@ type Duration = | "moreThanFiveYears" | "moreThanTenYears"; -export interface Admissibility { - id: string; - isCandidateAlreadyAdmissible: boolean; - reportSentAt: Date | null; - certifierRespondedAt: Date | null; - responseAvailableToCandidateAt: Date | null; - status: AdmissibilityStatus | null; -} - -type AdmissibilityStatus = "ADMISSIBLE" | "NOT_ADMISSIBLE"; - export enum CandidacyBusinessEvent { SUBMITTED_CANDIDACY = "Submitted Candidacy", TOOK_OVER_CANDIDACY = "Took over candidacy", @@ -55,13 +45,13 @@ export enum CandidacyBusinessEvent { SELECTED_ORGANISM = "Selected organism", SUBMITTED_TRAINING_FORM = "Submitted training form", CONFIRMED_TRAINING_FORM = "Confirmed training form", - UPDATED_ADMISSIBILITY = "Updated admissibility", DROPPED_OUT_CANDIDACY = "Dropped out candidacy", CANCELED_DROPPED_OUT_CANDIDACY = "Canceled dropped out candidacy", VALIDATED_DROPPED_OUT_CANDIDACY = "Validated dropped out candidacy", UPDATED_EXAM_INFO = "Updated exam information", CREATED_FUNDING_REQUEST_UNIFVAE = "Created a funding request (unifvae)", } + export const candidacyStatusFilters = [ "ACTIVE_HORS_ABANDON", "ABANDON", diff --git a/packages/reva-api/modules/candidacy/features/getAdmissibilityByCandidacyId.ts b/packages/reva-api/modules/candidacy/features/getAdmissibilityByCandidacyId.ts deleted file mode 100644 index dba4b519c..000000000 --- a/packages/reva-api/modules/candidacy/features/getAdmissibilityByCandidacyId.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { prismaClient } from "../../../prisma/client"; - -export const getAdmissibilityByCandidacyId = async ({ - candidacyId, -}: { - candidacyId: string; -}) => - prismaClient.admissibility.findUnique({ - where: { - candidacyId, - }, - }); diff --git a/packages/reva-api/modules/candidacy/features/updateAdmissibility.ts b/packages/reva-api/modules/candidacy/features/updateAdmissibility.ts deleted file mode 100644 index e09bd40d9..000000000 --- a/packages/reva-api/modules/candidacy/features/updateAdmissibility.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { isBefore } from "date-fns"; - -import { Admissibility } from "../candidacy.types"; -import { getAdmissibilityByCandidacyId } from "./getAdmissibilityByCandidacyId"; -import { prismaClient } from "../../../prisma/client"; -import { logCandidacyAuditEvent } from "../../candidacy-log/features/logCandidacyAuditEvent"; - -const isBefore2019 = (date: Date) => isBefore(date, new Date(2019, 0)); - -export const updateAdmissibility = async ({ - candidacyId, - admissibility, - userKeycloakId, - userEmail, - userRoles, -}: { - candidacyId: string; - admissibility: Partial; - userKeycloakId?: string; - userEmail?: string; - userRoles: KeyCloakUserRole[]; -}) => { - if (admissibility.reportSentAt && isBefore2019(admissibility.reportSentAt)) { - throw new Error( - "La date d'envoi du dossier de la faisabilité doit être après 2019 ", - ); - } - if ( - admissibility.certifierRespondedAt && - isBefore2019(admissibility.certifierRespondedAt) - ) { - throw new Error( - "La date du prononcé de la recevabilité doit être après 2019 ", - ); - } - if ( - admissibility.responseAvailableToCandidateAt && - isBefore2019(admissibility.responseAvailableToCandidateAt) - ) { - throw new Error( - "La date de réception de l'avis de recevabilité doit être après 2019", - ); - } - - const existingAdmissibility = await getAdmissibilityByCandidacyId({ - candidacyId, - }); - - if (!existingAdmissibility) { - throw new Error("Erreur admissibilité non trouvé pour la candidature"); - } - - const result = await prismaClient.admissibility.update({ - where: { id: existingAdmissibility.id }, - data: { - ...existingAdmissibility, - certifierRespondedAt: null, - reportSentAt: null, - responseAvailableToCandidateAt: null, - status: null, - ...admissibility, - }, - }); - - await logCandidacyAuditEvent({ - candidacyId, - eventType: "ADMISSIBILITY_UPDATED", - userKeycloakId, - userEmail, - userRoles, - }); - - return result; -}; diff --git a/packages/reva-api/modules/candidacy/security/security.ts b/packages/reva-api/modules/candidacy/security/security.ts index 6e4e8e5cd..561bc2fc9 100644 --- a/packages/reva-api/modules/candidacy/security/security.ts +++ b/packages/reva-api/modules/candidacy/security/security.ts @@ -42,11 +42,8 @@ export const resolversSecurityMap = { "Mutation.candidacy_dropOut": isAdminOrCandidacyCompanion, "Mutation.candidacy_validateDropOut": isAdmin, "Mutation.candidacy_cancelDropOutById": isAdmin, - "Mutation.candidacy_updateAdmissibility": isAdminOrCandidacyCompanion, "Mutation.candidacy_createOrUpdatePaymentRequest": isAdminOrCandidacyCompanion, "Mutation.candidacy_confirmPaymentRequest": isAdminOrCandidacyCompanion, "Mutation.candidacy_setReadyForJuryEstimatedAt": isOwnerOrCanManageCandidacy, - - "Candidacy.admissibility": isAdminOrCandidacyCompanion, };