Skip to content

Commit

Permalink
chore(api): removed updateCandidacyStatus from the candidacy database…
Browse files Browse the repository at this point in the history
… file. Use the one in Candidacy/features instead
  • Loading branch information
agarbe committed Aug 9, 2024
1 parent e1035a9 commit 2e54c1d
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 45 deletions.
33 changes: 0 additions & 33 deletions packages/reva-api/modules/candidacy/database/candidacies.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
import { CandidacyStatusStep } from "@prisma/client";

import { prismaClient } from "../../../prisma/client";

export const updateCandidacyStatus = async (params: {
candidacyId: string;
status: CandidacyStatusStep;
}) => {
const [, newCandidacy] = await prismaClient.$transaction([
prismaClient.candidaciesStatus.updateMany({
where: {
candidacyId: params.candidacyId,
},
data: {
isActive: false,
},
}),
prismaClient.candidacy.update({
where: {
id: params.candidacyId,
},
data: {
candidacyStatuses: {
create: {
status: params.status,
isActive: true,
},
},
},
}),
]);

return newCandidacy;
};

export const updateOrganism = async (params: {
candidacyId: string;
organismId: string | null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { CandidacyStatusStep } from "@prisma/client";

import { prismaClient } from "../../../prisma/client";
import * as domain from "../candidacy.types";

export const updateCandidacyStatus = async (params: {
candidacyId: string;
status: CandidacyStatusStep;
}): Promise<domain.Candidacy> => {
}) => {
const [, newCandidacy] = await prismaClient.$transaction([
prismaClient.candidaciesStatus.updateMany({
where: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
CandidacyAuditLogUserInfo,
logCandidacyAuditEvent,
} from "../../../candidacy-log/features/logCandidacyAuditEvent";
import { updateCandidacyStatus } from "../../../candidacy/database/candidacies";
import { existsCandidacyWithActiveStatus } from "../../../candidacy/features/existsCandidacyWithActiveStatus";
import { getCertificationByCandidacyId } from "../../../certification/features/getCertificationByCandidacyId";
import { updateCandidacyStatus } from "../../features/updateCandidacyStatus";

export const confirmTrainingFormByCandidate = async ({
candidacyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
CandidacyAuditLogUserInfo,
logCandidacyAuditEvent,
} from "../../../candidacy-log/features/logCandidacyAuditEvent";
import { updateCandidacyStatus } from "../../../candidacy/database/candidacies";
import { generateJwt } from "../../../candidate/auth.helper";
import { sendTrainingEmail } from "../emails";
import { existsCandidacyHavingHadStatus } from "./existsCandidacyHavingHadStatus";
import { updateTrainingInformations } from "./updateTrainingInformations";
import { getCandidateById } from "../../features/getCandidateById";
import { updateCandidacyStatus } from "../../features/updateCandidacyStatus";

export const submitTraining = async ({
candidacyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { CandidacyStatusStep } from "@prisma/client";

import { prismaClient } from "../../../prisma/client";
import { logCandidacyAuditEvent } from "../../candidacy-log/features/logCandidacyAuditEvent";
import {
updateCandidacyStatus,
updateOrganism,
} from "../../candidacy/database/candidacies";
import { updateOrganism } from "../../candidacy/database/candidacies";
import { canCandidateUpdateCandidacy } from "../../candidacy/features/canCandidateUpdateCandidacy";
import { existsCandidacyWithActiveStatus } from "../../candidacy/features/existsCandidacyWithActiveStatus";
import { getCertificationById } from "../../referential/features/getCertificationById";
Expand All @@ -15,6 +12,7 @@ import {
} from "../../shared/error/functionalError";
import { logger } from "../../shared/logger";
import { updateCertification } from "./updateCertification";
import { updateCandidacyStatus } from "../../candidacy/features/updateCandidacyStatus";

export const updateCertificationOfCandidacy = async ({
candidacyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { CandidacyStatusStep } from "@prisma/client";
import { prismaClient } from "../../../prisma/client";
import { Role } from "../../account/account.types";
import { logCandidacyAuditEvent } from "../../candidacy-log/features/logCandidacyAuditEvent";
import { updateCandidacyStatus } from "../../candidacy/database/candidacies";
import { getCertificationById } from "../../referential/features/getCertificationById";
import {
FunctionalCodeError,
FunctionalError,
} from "../../shared/error/functionalError";
import { updateCertification } from "./updateCertification";
import { updateCandidacyStatus } from "../../candidacy/features/updateCandidacyStatus";

export const updateCertificationWithinOrganismScope = async ({
hasRole,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { Account } from "../account/account.types";
import { getAccountById } from "../account/features/getAccount";
import { getAccountByKeycloakId } from "../account/features/getAccountByKeycloakId";
import { logCandidacyAuditEvent } from "../candidacy-log/features/logCandidacyAuditEvent";
import { updateCandidacyStatus } from "../candidacy/database/candidacies";
import { canManageCandidacy } from "../candidacy/features/canManageCandidacy";
import { candidacySearchWord } from "../candidacy/utils/candidacy.helper";
import { getCertificationAuthorityLocalAccountByAccountId } from "../certification-authority/features/getCertificationAuthorityLocalAccountByAccountId";
Expand All @@ -38,6 +37,7 @@ import {
excludeRejectedArchivedAndDroppedOutCandidacy,
getWhereClauseFromStatusFilter,
} from "./utils/feasibility.helper";
import { updateCandidacyStatus } from "../candidacy/features/updateCandidacyStatus";

const baseUrl = process.env.BASE_URL || "https://vae.gouv.fr";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { format, isBefore } from "date-fns";

import { prismaClient } from "../../../../prisma/client";
import { logCandidacyAuditEvent } from "../../../candidacy-log/features/logCandidacyAuditEvent";
import { updateCandidacyStatus } from "../../../candidacy/database/candidacies";
import { UploadedFile } from "../../../shared/file";
import { applyBusinessValidationRules } from "../validation";
import { createBatchFromFundingRequestUnifvae } from "./fundingRequestBatch";
import { updateCandidacyStatus } from "../../../candidacy/features/updateCandidacyStatus";

export const createFundingRequestUnifvae = async ({
candidacyId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PaymentRequest, PaymentRequestBatchContent } from "../finance.types";
import { FundingRequest } from "@prisma/client";
import { updateCandidacyStatus } from "../../../candidacy/database/candidacies";
import { existsCandidacyWithActiveStatus } from "../../../candidacy/features/existsCandidacyWithActiveStatus";
import { getCandidacy } from "../../../candidacy/features/getCandidacy";
import { createPaymentRequestBatch } from "../database/paymentRequestBatches";
import { getFundingRequestByCandidacyId } from "./getFundingRequestByCandidacyId";
import { getPaymentRequestByCandidacyId } from "./getPaymentRequestByCandidacyId";
import { getOrganismById } from "../../../organism/features/getOrganism";
import { updateCandidacyStatus } from "../../../candidacy/features/updateCandidacyStatus";

export const confirmPaymentRequest = async ({
candidacyId,
Expand Down

0 comments on commit 2e54c1d

Please sign in to comment.