Skip to content

Commit

Permalink
♻️ Attribution du GRD à la désignation (#2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjlevesque authored Jan 6, 2025
1 parent b04a859 commit f382ff4
Show file tree
Hide file tree
Showing 47 changed files with 581 additions and 826 deletions.
4 changes: 0 additions & 4 deletions cron.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"command": "0 8 * * 0 ./packages/applications/scheduled-tasks/mettre-à-jour-gestionnaire-réseau.sh",
"size": "M"
},
{
"command": "0 8 * * 1-5 ./packages/applications/scheduled-tasks/attribuer-grd.sh",
"size": "M"
},
{
"command": "0 0 * * * ./packages/applications/scheduled-tasks/s3-backup.sh",
"size": "M"
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/applications/bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@potentiel-domain/tache": "*",
"@potentiel-infrastructure/domain-adapters": "*",
"@potentiel-infrastructure/email": "*",
"@potentiel-infrastructure/ore-client": "*",
"@potentiel-infrastructure/pg-event-sourcing": "*",
"@potentiel-infrastructure/pg-projections": "*",
"@potentiel-libraries/pg-helpers": "*",
Expand Down
40 changes: 23 additions & 17 deletions packages/applications/bootstrap/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Middleware, mediator } from 'mediateur';

import { getLogger } from '@potentiel-libraries/monitoring';
import { SendEmail } from '@potentiel-applications/notifications';
import { sendEmail as sendEmailMailjet } from '@potentiel-infrastructure/email';
import { sendEmail } from '@potentiel-infrastructure/email';
import { executeSubscribersRetry } from '@potentiel-infrastructure/pg-event-sourcing';
import { récupérerGRDParVille } from '@potentiel-infrastructure/ore-client';

import { setupLauréat } from './setupLauréat';
import { setupCandidature } from './setupCandidature';
Expand All @@ -22,13 +22,19 @@ import { setupStatistiques } from './setupStatistiques';
let unsubscribe: (() => Promise<void>) | undefined;
let mutex: Promise<void> | undefined;

export const bootstrap = async ({
middlewares,
const defaultDependencies = {
sendEmail,
}: {
récupérerGRDParVille,
};

type BootstrapProps = {
middlewares: Array<Middleware>;
sendEmail?: SendEmail;
}): Promise<() => Promise<void>> => {
dependencies?: Partial<typeof defaultDependencies>;
};
export const bootstrap = async ({
middlewares,
dependencies,
}: BootstrapProps): Promise<() => Promise<void>> => {
// if there's already a bootstrap operation in progress, wait for it to finish
if (mutex) {
await mutex;
Expand All @@ -40,26 +46,26 @@ export const bootstrap = async ({
mediator.use({
middlewares: [logMiddleware, ...middlewares],
});

if (!sendEmail) {
sendEmail = sendEmailMailjet;
}
const allDependencies = {
...defaultDependencies,
...dependencies,
};

const unsetupHistorique = await setupHistorique();

setupStatistiques();
setupUtilisateur();
await setupAppelOffre();
setupDocumentProjet();
const unsetupCandidature = await setupCandidature({ sendEmail });
const unsetupPériode = await setupPériode({ sendEmail });
const unsetupCandidature = await setupCandidature(allDependencies);
const unsetupPériode = await setupPériode(allDependencies);

const unsetupTâche = await setupTâche();
const unsetupTâchePlanifiée = await setupTâchePlanifiée({ sendEmail });
const unsetupTâchePlanifiée = await setupTâchePlanifiée(allDependencies);

const unsetupEliminé = await setupEliminé({ sendEmail });
const unsetupLauréat = await setupLauréat({ sendEmail });
const unsetupGestionnaireRéseau = await setupRéseau();
const unsetupEliminé = await setupEliminé(allDependencies);
const unsetupLauréat = await setupLauréat(allDependencies);
const unsetupGestionnaireRéseau = await setupRéseau(allDependencies);

getLogger().info('Application bootstrapped');

Expand Down
29 changes: 24 additions & 5 deletions packages/applications/bootstrap/src/setupRéseau.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
listProjection,
} from '@potentiel-infrastructure/pg-projections';

export const setupRéseau = async () => {
type SetupRéseauDependencies = {
récupérerGRDParVille: Raccordement.RécupererGRDParVillePort;
};
export const setupRéseau = async ({ récupérerGRDParVille }: SetupRéseauDependencies) => {
registerRéseauUseCases({
loadAggregate,
});
Expand All @@ -32,7 +35,9 @@ export const setupRéseau = async () => {
RaccordementProjector.register();

// Sagas
Raccordement.RaccordementSaga.register();
Raccordement.RaccordementSaga.register({
récupérerGRDParVille,
});

const unsubscribeGestionnaireRéseauProjector =
await subscribe<GestionnaireRéseauProjector.SubscriptionEvent>({
Expand Down Expand Up @@ -88,10 +93,10 @@ export const setupRéseau = async () => {
},
);

const unsubscribeRaccordementSaga = await subscribe<
const unsubscribeRaccordementAbandonSaga = await subscribe<
Raccordement.RaccordementSaga.SubscriptionEvent & Event
>({
name: 'raccordement-saga',
name: 'raccordement-abandon-saga',
streamCategory: 'abandon',
eventType: ['AbandonAccordé-V1'],
eventHandler: async (event) => {
Expand All @@ -101,10 +106,24 @@ export const setupRéseau = async () => {
});
},
});
const unsubscribeRaccordementLauréatSaga = await subscribe<
Raccordement.RaccordementSaga.SubscriptionEvent & Event
>({
name: 'raccordement-laureat-saga',
streamCategory: 'lauréat',
eventType: ['LauréatNotifié-V1'],
eventHandler: async (event) => {
await mediator.publish<Raccordement.RaccordementSaga.Execute>({
type: 'System.Réseau.Raccordement.Saga.Execute',
data: event,
});
},
});

return async () => {
await unsubscribeGestionnaireRéseauProjector();
await unsubscribeRaccordementProjector();
await unsubscribeRaccordementSaga();
await unsubscribeRaccordementAbandonSaga();
await unsubscribeRaccordementLauréatSaga();
};
};
3 changes: 3 additions & 0 deletions packages/applications/bootstrap/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
{
"path": "../../infrastructure/email"
},
{
"path": "../../infrastructure/ore-client"
},
{
"path": "../../infrastructure/pg-event-sourcing"
},
Expand Down
19 changes: 0 additions & 19 deletions packages/applications/scheduled-tasks/attribuer-grd.sh

This file was deleted.

1 change: 0 additions & 1 deletion packages/applications/scheduled-tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"private": true,
"scripts": {
"build": "tsc",
"start:attribuer-grd": "node ./dist/raccordement/attribuer-gestionnaire-réseau",
"start:relancer-abandon-sans-preuve": "node ./dist/abandon/relancer-abandon-sans-preuve",
"start:déplacer-fichiers-vers-bucket-secnum": "node ./dist/déplacer-fichiers-vers-bucket-secnum",
"start:créer-backup": "node ./dist/backup/créer-backup",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ export const ModifierDemandeComplèteRaccordementForm: FC<
ValidationErrors<ModifierDemandeComplèteRaccordementFormKeys>
>({});

const { aideSaisieRéférenceDossierRaccordement, identifiantGestionnaireRéseau } =
gestionnaireRéseauActuel;
const { aideSaisieRéférenceDossierRaccordement } = gestionnaireRéseauActuel;

return (
<Form
Expand All @@ -82,11 +81,6 @@ export const ModifierDemandeComplèteRaccordementForm: FC<
>
<input name="identifiantProjet" type="hidden" value={identifiantProjet} />
<input name="referenceDossierRaccordementActuelle" type="hidden" value={référence.value} />
<input
name="identifiantGestionnaireReseau"
type="hidden"
value={identifiantGestionnaireRéseau}
/>

<div>
Gestionnaire réseau :{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { keepOrUpdateSingleDocument } from '@/utils/zod/document/keepOrUpdateDoc

const schema = zod.object({
identifiantProjet: zod.string().min(1),
identifiantGestionnaireReseau: zod.string().min(1),
dateQualification: zod.string().min(1, { message: 'Champ obligatoire' }),
referenceDossierRaccordement: zod.string().min(1),
referenceDossierRaccordementActuelle: zod.string().min(1),
Expand All @@ -25,7 +24,6 @@ const action: FormAction<FormState, typeof schema> = async (
_,
{
identifiantProjet,
identifiantGestionnaireReseau,
accuseReception,
dateQualification,
referenceDossierRaccordement,
Expand All @@ -49,7 +47,6 @@ const action: FormAction<FormState, typeof schema> = async (
type: 'Réseau.Raccordement.UseCase.ModifierDemandeComplèteRaccordement',
data: {
identifiantProjetValue: identifiantProjet,
identifiantGestionnaireRéseauValue: identifiantGestionnaireReseau,
accuséRéceptionValue: accuseReception,
dateQualificationValue: new Date(dateQualification).toISOString(),
référenceDossierRaccordementValue: referenceDossierRaccordement,
Expand Down
Loading

0 comments on commit f382ff4

Please sign in to comment.