Add submessages about low in commits
This commit is contained in:
parent
5b1771a3e6
commit
a05ecaaee3
1 changed files with 121 additions and 11 deletions
|
@ -5,7 +5,11 @@ import git from "isomorphic-git"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import sade from "sade"
|
import sade from "sade"
|
||||||
|
|
||||||
import type { JorfArticle, JorfTexteVersion } from "$lib/legal/jorf"
|
import type {
|
||||||
|
JorfArticle,
|
||||||
|
JorfTextelr,
|
||||||
|
JorfTexteVersion,
|
||||||
|
} from "$lib/legal/jorf"
|
||||||
import type {
|
import type {
|
||||||
LegiArticle,
|
LegiArticle,
|
||||||
LegiSectionTa,
|
LegiSectionTa,
|
||||||
|
@ -37,6 +41,7 @@ interface Context {
|
||||||
sectionTaById: Record<string, LegiSectionTa>
|
sectionTaById: Record<string, LegiSectionTa>
|
||||||
targetDir: string
|
targetDir: string
|
||||||
texteManquantById: Record<string, TexteManquant>
|
texteManquantById: Record<string, TexteManquant>
|
||||||
|
textelrById: Record<string, JorfTextelr | LegiTextelr | null>
|
||||||
texteModificateurIdByActionById: Record<
|
texteModificateurIdByActionById: Record<
|
||||||
string,
|
string,
|
||||||
Partial<Record<Action, string>>
|
Partial<Record<Action, string>>
|
||||||
|
@ -194,10 +199,15 @@ async function exportLegiTexteToMarkdown(
|
||||||
legiTexteInternalIds: new Set([legiTexteId]),
|
legiTexteInternalIds: new Set([legiTexteId]),
|
||||||
sectionTaById: {},
|
sectionTaById: {},
|
||||||
targetDir,
|
targetDir,
|
||||||
|
textelrById: {},
|
||||||
texteManquantById: {},
|
texteManquantById: {},
|
||||||
texteModificateurIdByActionById: {},
|
texteModificateurIdByActionById: {},
|
||||||
texteVersionById: {},
|
texteVersionById: {},
|
||||||
}
|
}
|
||||||
|
const textelr = (await getOrLoadTextelr(context, legiTexteId)) as
|
||||||
|
| JorfTextelr
|
||||||
|
| LegiTextelr
|
||||||
|
assert.notStrictEqual(textelr, null)
|
||||||
const texteVersion = (await getOrLoadTexteVersion(context, legiTexteId)) as
|
const texteVersion = (await getOrLoadTexteVersion(context, legiTexteId)) as
|
||||||
| JorfTexteVersion
|
| JorfTexteVersion
|
||||||
| LegiTexteVersion
|
| LegiTexteVersion
|
||||||
|
@ -207,13 +217,6 @@ async function exportLegiTexteToMarkdown(
|
||||||
// But for the Constitution, for example, the CID is the ID of the JORF text.
|
// But for the Constitution, for example, the CID is the ID of the JORF text.
|
||||||
context.legiTexteCid = meta.META_SPEC.META_TEXTE_CHRONICLE.CID
|
context.legiTexteCid = meta.META_SPEC.META_TEXTE_CHRONICLE.CID
|
||||||
|
|
||||||
const textelr = (
|
|
||||||
await db<{ data: LegiTextelr }[]>`
|
|
||||||
SELECT data FROM textelr WHERE id = ${legiTexteId}
|
|
||||||
`
|
|
||||||
)[0]?.data
|
|
||||||
assert.notStrictEqual(textelr, undefined)
|
|
||||||
|
|
||||||
const metaTexteVersion = meta.META_SPEC.META_TEXTE_VERSION
|
const metaTexteVersion = meta.META_SPEC.META_TEXTE_VERSION
|
||||||
console.log(
|
console.log(
|
||||||
`${meta.META_COMMUN.ID} ${metaTexteVersion.TITREFULL ?? metaTexteVersion.TITRE ?? meta.META_COMMUN.ID} (${metaTexteVersion.DATE_DEBUT ?? ""} — ${metaTexteVersion.DATE_FIN === "2999-01-01" ? "…" : (metaTexteVersion.DATE_FIN ?? "")}, ${metaTexteVersion.ETAT})`,
|
`${meta.META_COMMUN.ID} ${metaTexteVersion.TITREFULL ?? metaTexteVersion.TITRE ?? meta.META_COMMUN.ID} (${metaTexteVersion.DATE_DEBUT ?? ""} — ${metaTexteVersion.DATE_FIN === "2999-01-01" ? "…" : (metaTexteVersion.DATE_FIN ?? "")}, ${metaTexteVersion.ETAT})`,
|
||||||
|
@ -249,7 +252,12 @@ async function exportLegiTexteToMarkdown(
|
||||||
context,
|
context,
|
||||||
lienArticle["@id"],
|
lienArticle["@id"],
|
||||||
)) as LegiArticle
|
)) as LegiArticle
|
||||||
await registerLegiArticleModifiers(context, 0, lienArticle, article)
|
await registerLegiArticleModifiers(
|
||||||
|
context,
|
||||||
|
0,
|
||||||
|
lienArticle as LegiSectionTaLienArt,
|
||||||
|
article,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,6 +446,7 @@ async function exportLegiTexteToMarkdown(
|
||||||
context,
|
context,
|
||||||
texteModificateurId,
|
texteModificateurId,
|
||||||
)) as JorfTexteVersion | LegiTexteVersion
|
)) as JorfTexteVersion | LegiTexteVersion
|
||||||
|
assert.notStrictEqual(texteVersionModificateur, null)
|
||||||
texteModificateurTitle =
|
texteModificateurTitle =
|
||||||
texteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
texteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
||||||
.TITREFULL ??
|
.TITREFULL ??
|
||||||
|
@ -464,11 +473,90 @@ async function exportLegiTexteToMarkdown(
|
||||||
await generateTexteGitDirectory(
|
await generateTexteGitDirectory(
|
||||||
context,
|
context,
|
||||||
2,
|
2,
|
||||||
textelr,
|
textelr as LegiTextelr,
|
||||||
texteVersion as LegiTexteVersion,
|
texteVersion as LegiTexteVersion,
|
||||||
texteModificateurId,
|
texteModificateurId,
|
||||||
)
|
)
|
||||||
const t3 = performance.now()
|
const t3 = performance.now()
|
||||||
|
|
||||||
|
let messageLines: string | undefined = undefined
|
||||||
|
if (texteModificateurId.startsWith("JORFTEXT")) {
|
||||||
|
const jorfTexteVersionModificateur =
|
||||||
|
texteVersionModificateur as JorfTexteVersion
|
||||||
|
messageLines = [
|
||||||
|
[
|
||||||
|
"Autorité",
|
||||||
|
jorfTexteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
||||||
|
.AUTORITE,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Ministère",
|
||||||
|
jorfTexteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
||||||
|
.MINISTERE,
|
||||||
|
],
|
||||||
|
["Nature", jorfTexteVersionModificateur.META.META_COMMUN.NATURE],
|
||||||
|
[
|
||||||
|
"Date de début",
|
||||||
|
jorfTexteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
||||||
|
.DATE_DEBUT,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Date de fin",
|
||||||
|
jorfTexteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
||||||
|
.DATE_FIN,
|
||||||
|
],
|
||||||
|
["Identifiant", jorfTexteVersionModificateur.META.META_COMMUN.ID],
|
||||||
|
[
|
||||||
|
"NOR",
|
||||||
|
jorfTexteVersionModificateur.META.META_SPEC.META_TEXTE_CHRONICLE
|
||||||
|
.NOR,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Ancien identifiant",
|
||||||
|
jorfTexteVersionModificateur.META.META_COMMUN.ANCIEN_ID,
|
||||||
|
],
|
||||||
|
// TODO: Mettre l'URL dans le Git Tricoteuses
|
||||||
|
["URL", jorfTexteVersionModificateur.META.META_COMMUN.URL],
|
||||||
|
]
|
||||||
|
.filter(([, value]) => value !== undefined)
|
||||||
|
.map(([key, value]) => `${key}: ${value}`)
|
||||||
|
.join("\n")
|
||||||
|
} else if (texteModificateurId.startsWith("LEGITEXT")) {
|
||||||
|
const legiTexteVersionModificateur =
|
||||||
|
texteVersionModificateur as LegiTexteVersion
|
||||||
|
messageLines = [
|
||||||
|
[
|
||||||
|
"État",
|
||||||
|
legiTexteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION.ETAT,
|
||||||
|
],
|
||||||
|
["Nature", legiTexteVersionModificateur.META.META_COMMUN.NATURE],
|
||||||
|
[
|
||||||
|
"Date de début",
|
||||||
|
legiTexteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
||||||
|
.DATE_DEBUT,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Date de fin",
|
||||||
|
legiTexteVersionModificateur.META.META_SPEC.META_TEXTE_VERSION
|
||||||
|
.DATE_FIN,
|
||||||
|
],
|
||||||
|
["Identifiant", legiTexteVersionModificateur.META.META_COMMUN.ID],
|
||||||
|
[
|
||||||
|
"NOR",
|
||||||
|
legiTexteVersionModificateur.META.META_SPEC.META_TEXTE_CHRONICLE
|
||||||
|
.NOR,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Ancien identifiant",
|
||||||
|
legiTexteVersionModificateur.META.META_COMMUN.ANCIEN_ID,
|
||||||
|
],
|
||||||
|
// TODO: Mettre l'URL dans le Git Tricoteuses
|
||||||
|
["URL", legiTexteVersionModificateur.META.META_COMMUN.URL],
|
||||||
|
]
|
||||||
|
.filter(([, value]) => value !== undefined)
|
||||||
|
.map(([key, value]) => `${key}: ${value}`)
|
||||||
|
.join("\n")
|
||||||
|
}
|
||||||
await git.commit({
|
await git.commit({
|
||||||
dir: targetDir,
|
dir: targetDir,
|
||||||
fs,
|
fs,
|
||||||
|
@ -476,7 +564,9 @@ async function exportLegiTexteToMarkdown(
|
||||||
email: "codes_juridiques@tricoteuses.fr",
|
email: "codes_juridiques@tricoteuses.fr",
|
||||||
name: "République française",
|
name: "République française",
|
||||||
},
|
},
|
||||||
message: texteModificateurTitle,
|
message: [texteModificateurTitle, messageLines]
|
||||||
|
.filter((block) => block !== undefined)
|
||||||
|
.join("\n\n"),
|
||||||
})
|
})
|
||||||
const t4 = performance.now()
|
const t4 = performance.now()
|
||||||
console.log(`Durations: ${t2 - t1} ${t3 - t2} ${t4 - t3}`)
|
console.log(`Durations: ${t2 - t1} ${t3 - t2} ${t4 - t3}`)
|
||||||
|
@ -907,6 +997,26 @@ async function getOrLoadSectionTa(
|
||||||
return sectionTa
|
return sectionTa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getOrLoadTextelr(
|
||||||
|
context: Context,
|
||||||
|
texteId: string,
|
||||||
|
): Promise<JorfTextelr | LegiTextelr | null> {
|
||||||
|
let textelr: JorfTextelr | LegiTextelr | null = context.textelrById[texteId]
|
||||||
|
if (textelr === undefined) {
|
||||||
|
textelr = (
|
||||||
|
await db<{ data: JorfTextelr | LegiTextelr }[]>`
|
||||||
|
SELECT data FROM textelr WHERE id = ${texteId}
|
||||||
|
`
|
||||||
|
)[0]?.data
|
||||||
|
if (textelr === undefined) {
|
||||||
|
console.warn(`Texte ${texteId} not found in table textelr`)
|
||||||
|
textelr = null
|
||||||
|
}
|
||||||
|
context.textelrById[texteId] = textelr
|
||||||
|
}
|
||||||
|
return textelr
|
||||||
|
}
|
||||||
|
|
||||||
async function getOrLoadTexteVersion(
|
async function getOrLoadTexteVersion(
|
||||||
context: Context,
|
context: Context,
|
||||||
texteId: string,
|
texteId: string,
|
||||||
|
|
Loading…
Reference in a new issue