Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rattacher les Animations Collectives aux structures Milo #1319

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"migration": "sequelize db:migrate",
"psql": "docker compose exec apidb psql -h localhost -d passemploidb -U passemploi ",
"seed": "sequelize db:seed:undo:all && sequelize db:seed:all",
"seed:referentiel": "sequelize db:seed:undo --seed 20211201160540-referentiel-communes-et-departements.js && sequelize db:seed --seed 20211201160540-referentiel-communes-et-departements.js && sequelize db:seed:undo --seed 20220420160540-referentiel-agences.js && sequelize db:seed --seed 20220420160540-referentiel-agences.js && sequelize db:seed:undo --seed 20221004160540-referentiel-rome.js && sequelize db:seed --seed 20221004160540-referentiel-rome.js",
"seed:referentiel:metiers": "sequelize db:seed:undo --seed 20221004160540-referentiel-rome.js && sequelize db:seed --seed 20221004160540-referentiel-rome.js",
"seed:referentiel": "sequelize db:seed:undo --seed 1-referentiel-communes-et-departements.js && sequelize db:seed --seed 1-referentiel-communes-et-departements.js && sequelize db:seed:undo --seed 1-referentiel-agences.js && sequelize db:seed --seed 1-referentiel-agences.js && sequelize db:seed:undo --seed 1-referentiel-rome.js && sequelize db:seed --seed 1-referentiel-rome.js",
"seed:referentiel:metiers": "sequelize db:seed:undo --seed 1-referentiel-rome.js && sequelize db:seed --seed 1-referentiel-rome.js",
"start": "yarn start:pg:db && nest start",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
Expand Down Expand Up @@ -56,7 +56,6 @@
"tasks:nettoyer-les-pieces-jointes": "IS_WEB=false TASK_NAME=NETTOYER_LES_PIECES_JOINTES node dist/main",
"tasks:nettoyer-les-donnees": "IS_WEB=false TASK_NAME=NETTOYER_LES_DONNEES node dist/main",
"tasks:notifier-rendez-vous-pe": "IS_WEB=false TASK_NAME=NOTIFIER_RENDEZVOUS_PE node dist/main",
"tasks:maj-agences-ac": "IS_WEB=false TASK_NAME=MAJ_AGENCE_AC node dist/main",
"tasks:maj-segments": "IS_WEB=false TASK_NAME=MAJ_SEGMENTS node dist/main",
"tasks:monitorer-jobs": "IS_WEB=false TASK_NAME=MONITORER_JOBS node dist/main",
"tasks:suivre-events-milo": "IS_WEB=false TASK_NAME=SUIVRE_FILE_EVENEMENTS_MILO node dist/main",
Expand Down
30 changes: 0 additions & 30 deletions scripts/data-migrations/mettre-a-jour-agences-milo.js

This file was deleted.

30 changes: 0 additions & 30 deletions scripts/data-migrations/mettre-a-jour-doublons-agences-milo.js

This file was deleted.

15 changes: 0 additions & 15 deletions scripts/data-migrations/purger-sessions-milo.js

This file was deleted.

33 changes: 33 additions & 0 deletions scripts/data-migrations/structures-milo-ac.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require('dotenv').config()
const { Sequelize } = require('sequelize')
const sequelize = new Sequelize(process.env.DATABASE_URL, {
dialect: 'postgres'
})

sequelize.transaction(async transaction => {
const ACsRAW = await sequelize.query(
`SELECT * FROM rendez_vous WHERE rendez_vous.type = 'ATELIER' OR rendez_vous.type = 'INFORMATION_COLLECTIVE'`
)
const ACs = ACsRAW[0]
for (const AC of ACs) {
const idStructureRaw = await sequelize.query(
`SELECT conseiller.id_structure_milo AS id_structure_milo FROM conseiller WHERE conseiller.id = '${AC.createur.id}'`,
{ transaction }
)
const idStructure = idStructureRaw[0][0].id_structure_milo

if (idStructure)
await sequelize.query(
`UPDATE rendez_vous SET id_structure_milo = '${idStructure}' WHERE rendez_vous.id = '${AC.id}'`
)
}
await sequelize.query(
`UPDATE rendez_vous SET date_suppression = NOW() WHERE (rendez_vous.type = 'ATELIER' OR rendez_vous.type = 'INFORMATION_COLLECTIVE') AND rendez_vous.id_structure_milo IS NULL`
)

await sequelize.query(`DELETE FROM rendez_vous_jeune_association WHERE id IN (SELECT rendez_vous_jeune_association.id FROM rendez_vous_jeune_association, jeune, rendez_vous
WHERE rendez_vous.id_structure_milo IS NOT null
AND rendez_vous.id = rendez_vous_jeune_association.id_rendez_vous
AND rendez_vous_jeune_association.id_jeune = jeune.id
AND jeune.id_structure_milo != rendez_vous.id_structure_milo)`)
})
2 changes: 0 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ import { ListesDeDiffusionController } from './infrastructure/routes/listes-de-d
import { ListeDeDiffusionAuthorizer } from './application/authorizers/liste-de-diffusion-authorizer'
import { UpdateListeDeDiffusionCommandHandler } from './application/commands/update-liste-de-diffusion.command.handler'
import { GetDetailListeDeDiffusionQueryHandler } from './application/queries/get-detail-liste-de-diffusion.query.handler.db'
import { MajAgenceAnimationCollectiveJobHandler } from './application/jobs/maj-agence-animation-collective.job.handler.db'
import { BigqueryClient } from './infrastructure/clients/bigquery.client'
import { MessagesController } from './infrastructure/routes/messages.controller'
import { SupportController } from './infrastructure/routes/support.controller'
Expand Down Expand Up @@ -797,7 +796,6 @@ export const JobHandlerProviders = [
EnvoyerEmailsMessagesConseillersJobHandler,
NotifierRecherchesOffreEmploiJobHandler,
RecupererSituationsJeunesMiloJobHandler,
MajAgenceAnimationCollectiveJobHandler,
MajCodesEvenementsJobHandler,
NotifierRappelInstanceSessionMiloJobHandler,
NotifierRendezVousPEJobHandler,
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions src/domain/planificateur.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export namespace Planificateur {
NOTIFIER_RENDEZVOUS_PE = 'NOTIFIER_RENDEZVOUS_PE',
MAJ_CODES_EVENEMENTS = 'MAJ_CODES_EVENEMENTS',
MAJ_SEGMENTS = 'MAJ_SEGMENTS',
MAJ_AGENCE_AC = 'MAJ_AGENCE_AC',
MONITORER_JOBS = 'MONITORER_JOBS',
GENERER_JDD = 'GENERER_JDD',
SUIVRE_FILE_EVENEMENTS_MILO = 'SUIVRE_FILE_EVENEMENTS_MILO',
Expand Down Expand Up @@ -172,12 +171,6 @@ export const listeCronJobs: Planificateur.CronJob[] = [
expression: '0 */2 * * *',
description: 'Toutes les 2 heures.'
},
{
type: Planificateur.JobType.MAJ_AGENCE_AC,
expression: '0 3 * * *',
description:
'Tous les jours à 3h. Cohérence AC avec agence du conseiller créateur.'
},
{
type: Planificateur.JobType.MONITORER_JOBS,
expression: '45 9 * * *',
Expand Down
1 change: 1 addition & 0 deletions src/domain/rendez-vous/rendez-vous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface RendezVous {
icsSequence?: number
createur: Createur
idAgence?: string
idStructureMilo?: string
dateCloture?: DateTime
informationsPartenaire?: RendezVous.InformationsPartenaire
nombreMaxParticipants?: number
Expand Down
1 change: 1 addition & 0 deletions src/infrastructure/jdd/rendez-vous.jdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function unRendezVousJDD(
icsSequence: null,
dateCloture: null,
idAgence: null,
idStructureMilo: null,
createur: { id: '1', nom: 'Tavernier', prenom: 'Nils' },
typePartenaire: null,
idPartenaire: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function toRendezVousDto(rendezVous: RendezVous): AsSql<RendezVousDto> {
icsSequence: rendezVous.icsSequence ?? null,
createur: rendezVous.createur,
idAgence: rendezVous.idAgence ?? null,
idStructureMilo: rendezVous.idStructureMilo ?? null,
typePartenaire: rendezVous.informationsPartenaire?.type ?? null,
idPartenaire: rendezVous.informationsPartenaire?.id ?? null,
nombreMaxParticipants: rendezVous.nombreMaxParticipants ?? null
Expand Down Expand Up @@ -59,6 +60,7 @@ export function toRendezVous(rendezVousSql: RendezVousSqlModel): RendezVous {
createur: rendezVousSql.createur,
dateCloture: DateService.fromJSDateToDateTime(rendezVousSql.dateCloture),
idAgence: rendezVousSql.idAgence ?? undefined,
idStructureMilo: rendezVousSql.idStructureMilo ?? undefined,
informationsPartenaire: buildInformationsPartenaire(rendezVousSql),
nombreMaxParticipants: rendezVousSql.nombreMaxParticipants ?? undefined
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.transaction(async transaction => {
await queryInterface.addColumn(
'rendez_vous',
'id_structure_milo',
{
type: Sequelize.STRING,
references: {
model: 'structure_milo',
key: 'id'
},
allowNull: true
},
{ transaction }
)
})
},

down: async queryInterface => {
await queryInterface.sequelize.transaction(async transaction => {
await queryInterface.removeColumn('rendez_vous', 'id_structure_milo', {
transaction
})
})
}
}
8 changes: 8 additions & 0 deletions src/infrastructure/sequelize/models/rendez-vous.sql-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AgenceSqlModel } from './agence.sql-model'
import { JeuneSqlModel } from './jeune.sql-model'
import { RendezVousJeuneAssociationSqlModel } from './rendez-vous-jeune-association.sql-model'
import { LogModificationRendezVousSqlModel } from './log-modification-rendez-vous-sql.model'
import { StructureMiloSqlModel } from './structure-milo.sql-model'

export class RendezVousDto extends Model {
@PrimaryKey
Expand Down Expand Up @@ -84,6 +85,13 @@ export class RendezVousDto extends Model {
})
idAgence: string | null

@ForeignKey(() => StructureMiloSqlModel)
@Column({
field: 'id_structure_milo',
type: DataType.STRING
})
idStructureMilo: string | null

@Column({
field: 'type_partenaire',
type: DataType.STRING
Expand Down
16 changes: 0 additions & 16 deletions src/infrastructure/sequelize/seeders/data/agences_milo_170223.json

This file was deleted.

Loading