Allow several dossiers to share the same law
This commit is contained in:
parent
b252fd636e
commit
0865340cd7
1 changed files with 22 additions and 17 deletions
|
@ -17,7 +17,7 @@ async function associateDossiersLegislatifsWithAssemblee({
|
||||||
).map(({ id }) => id),
|
).map(({ id }) => id),
|
||||||
)
|
)
|
||||||
|
|
||||||
const dossierIdByLawId: { [nor: string]: string } = {}
|
const dossiersIdByLawId: { [nor: string]: Set<string> } = {}
|
||||||
const lawIdByNor: { [nor: string]: string } = {}
|
const lawIdByNor: { [nor: string]: string } = {}
|
||||||
for (const dossier of (
|
for (const dossier of (
|
||||||
await db<{ data: DossierLegislatif }[]>`
|
await db<{ data: DossierLegislatif }[]>`
|
||||||
|
@ -63,7 +63,11 @@ async function associateDossiersLegislatifsWithAssemblee({
|
||||||
const nor = textelr.META.META_SPEC.META_TEXTE_CHRONICLE.NOR
|
const nor = textelr.META.META_SPEC.META_TEXTE_CHRONICLE.NOR
|
||||||
assert.notStrictEqual(nor, undefined)
|
assert.notStrictEqual(nor, undefined)
|
||||||
lawIdByNor[nor as string] = idTexte
|
lawIdByNor[nor as string] = idTexte
|
||||||
dossierIdByLawId[idTexte] = dossier.META.META_COMMUN.ID
|
let lawDossiersId = dossiersIdByLawId[idTexte]
|
||||||
|
if (lawDossiersId === undefined) {
|
||||||
|
lawDossiersId = dossiersIdByLawId[idTexte] = new Set<string>()
|
||||||
|
}
|
||||||
|
dossiersIdByLawId[idTexte].add(dossier.META.META_COMMUN.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lawsId.size === 0) {
|
if (lawsId.size === 0) {
|
||||||
|
@ -110,7 +114,7 @@ async function associateDossiersLegislatifsWithAssemblee({
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
assert.notStrictEqual(lawId, undefined)
|
assert.notStrictEqual(lawId, undefined)
|
||||||
const dossierId = dossierIdByLawId[lawId]
|
for (const dossierId of dossiersIdByLawId[lawId]) {
|
||||||
assert.notStrictEqual(dossierId, undefined)
|
assert.notStrictEqual(dossierId, undefined)
|
||||||
await db`
|
await db`
|
||||||
INSERT INTO dossier_legislatif_assemblee_associations (
|
INSERT INTO dossier_legislatif_assemblee_associations (
|
||||||
|
@ -126,6 +130,7 @@ async function associateDossiersLegislatifsWithAssemblee({
|
||||||
`
|
`
|
||||||
dossierAssociationRemainingIds.delete(dossierId)
|
dossierAssociationRemainingIds.delete(dossierId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const id of dossierAssociationRemainingIds) {
|
for (const id of dossierAssociationRemainingIds) {
|
||||||
console.log(
|
console.log(
|
||||||
|
|
Loading…
Reference in a new issue