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

Gateways : Visualiser la liste des membres de ma gouvernance #340

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ornella452
Copy link
Contributor

@Ornella452 Ornella452 commented Jan 30, 2025

Contrat du dev

Qualité

  • Relire le code
  • Relire le ticket
  • Vérifier le coverage

Facultatif mais fortement conseillé

  • Lancer les tests de mutation

Et n'oublie pas de vérifier ce que tu as fait en production !

@Ornella452 Ornella452 force-pushed the gererLesMembres_partie_gateways branch from e37d38a to 6796bed Compare January 30, 2025 17:12
Comment on lines +18 to +19
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const result = (await this.#dataResourceGouvernance.$queryRaw`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const result = (await this.#dataResourceGouvernance.$queryRaw`
const result: ReadonlyArray<Membres> = await this.#dataResourceGouvernance.$queryRaw`

Par défaut, les as sont en dernier recours

role: ReadonlyArray<string>
}
export class PrismaMesMembresLoader extends MesMembresLoader {
readonly #dataResourceGouvernance: PrismaClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly #dataResourceGouvernance: PrismaClient
readonly #dataResource PrismaClient

Pour être consistent avec les autres loaders

Comment on lines +5 to +8
interface Membres {
nomMembre: string
role: ReadonlyArray<string>
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
interface Membres {
nomMembre: string
role: ReadonlyArray<string>
}
type Membres = Readonly<{
nomMembre: string
role: ReadonlyArray<string>
}>

Une interface est faite pour être intanciée, hors, ce n'est pas le cas ici.
Et met le tout en bas du fichier car c'est moins important que la classe

UNION ALL
SELECT structure AS "nomMembre", ARRAY_AGG(role) AS role FROM membre_gouvernance_structure WHERE "gouvernanceDepartementCode" = ${codeDepartementGouvernance} GROUP BY structure
UNION ALL
SELECT departement.nom AS "nomMembre", ARRAY_AGG(membre_gouvernance_departement.role) AS role FROM membre_gouvernance_departement INNER JOIN departement ON membre_gouvernance_departement."departementCode" = departement.code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SELECT departement.nom AS "nomMembre", ARRAY_AGG(membre_gouvernance_departement.role) AS role FROM membre_gouvernance_departement INNER JOIN departement ON membre_gouvernance_departement."departementCode" = departement.code
SELECT departement.nom AS "nomMembre", ARRAY_AGG(membre_gouvernance_departement.role) AS role FROM membre_gouvernance_departement INNER JOIN departement ON membre_gouvernance_departement."departementCode" = departement.code

},
].map((membre) => ({
...membre,
roles: (result.find((membreDb: Membres) => membreDb.nomMembre === membre.nom)?.role ?? []) as ReadonlyArray<Role>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
roles: (result.find((membreDb: Membres) => membreDb.nomMembre === membre.nom)?.role ?? []) as ReadonlyArray<Role>,
roles: (result.find((membreDb: Membres) => membreDb.nomMembre === membre.nom)?.role ?? []) as MesMembresReadModel['roles'],

Comme tu peux éviter d'exporter Role

})
}

async function ajoutMembreGouvernanceCommune(): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pas mal ça, vu que l'on fait souvent ça et de manière répétitive, on pourrait les mettre dans le testHelper et les utiliser tout le temps !

})
})

async function preRequisGouvernanceRhone(): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ca serait plus auto portant de la découper en 3 pour mieux voir dans le GIVEN le scénario

@@ -0,0 +1,189 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supprimer la ligne

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants