Improve format of liens in database

This commit is contained in:
Emmanuel 2024-05-12 23:36:27 +02:00
parent b846817fbb
commit b7504d1947
10 changed files with 146 additions and 106 deletions

194
package-lock.json generated
View file

@ -35,7 +35,7 @@
"autoprefixer": "^10.4.7",
"daisyui": "^4.4.22",
"dotenv": "^16.0.1",
"eslint": "^8.16.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.28.0",
"fs-extra": "^11.1.0",
@ -1173,22 +1173,22 @@
}
},
"node_modules/@tricoteuses/assemblee/node_modules/glob": {
"version": "10.3.12",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz",
"integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==",
"version": "10.3.15",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.15.tgz",
"integrity": "sha512-0c6RlJt1TICLyvJYIApxb8GsXoai0KUP7AxKKAtsYXdgJR1mGEUa7DgwShbdk1nly0PYoZj01xd4hzbq3fsjpw==",
"dev": true,
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^2.3.6",
"minimatch": "^9.0.1",
"minipass": "^7.0.4",
"path-scurry": "^1.10.2"
"path-scurry": "^1.11.0"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"engines": {
"node": ">=16 || 14 >=14.17"
"node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@ -1382,6 +1382,58 @@
}
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.8.0.tgz",
"integrity": "sha512-H70R3AefQDQpz9mGv13Uhi121FNMh+WEaRqcXTX09YEDky21km4dV1ZXJIp8QjXc4ZaVkXVdohvWDzbnbHDS+A==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "7.8.0",
"@typescript-eslint/utils": "7.8.0",
"debug": "^4.3.4",
"ts-api-utils": "^1.3.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.56.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.8.0.tgz",
"integrity": "sha512-L0yFqOCflVqXxiZyXrDr80lnahQfSOfc9ELAAZ75sqicqp2i36kEZZGuUymHNFoYOqxRT05up760b4iGsl02nQ==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.15",
"@types/semver": "^7.5.8",
"@typescript-eslint/scope-manager": "7.8.0",
"@typescript-eslint/types": "7.8.0",
"@typescript-eslint/typescript-estree": "7.8.0",
"semver": "^7.6.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.56.0"
}
},
"node_modules/@typescript-eslint/parser": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.8.0.tgz",
@ -1427,33 +1479,6 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.8.0.tgz",
"integrity": "sha512-H70R3AefQDQpz9mGv13Uhi121FNMh+WEaRqcXTX09YEDky21km4dV1ZXJIp8QjXc4ZaVkXVdohvWDzbnbHDS+A==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "7.8.0",
"@typescript-eslint/utils": "7.8.0",
"debug": "^4.3.4",
"ts-api-utils": "^1.3.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.56.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/types": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.8.0.tgz",
@ -1495,31 +1520,6 @@
}
}
},
"node_modules/@typescript-eslint/utils": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.8.0.tgz",
"integrity": "sha512-L0yFqOCflVqXxiZyXrDr80lnahQfSOfc9ELAAZ75sqicqp2i36kEZZGuUymHNFoYOqxRT05up760b4iGsl02nQ==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.15",
"@types/semver": "^7.5.8",
"@typescript-eslint/scope-manager": "7.8.0",
"@typescript-eslint/types": "7.8.0",
"@typescript-eslint/typescript-estree": "7.8.0",
"semver": "^7.6.0"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.56.0"
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.8.0.tgz",
@ -1926,9 +1926,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001616",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz",
"integrity": "sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw==",
"version": "1.0.30001617",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz",
"integrity": "sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==",
"dev": true,
"funding": [
{
@ -2515,9 +2515,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.4.759",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.759.tgz",
"integrity": "sha512-qZJc+zsuI+/5UjOSFnpkJBwwLMH1AZgyKqJ7LUNnRsB7v/cDjMu9DvXgp9kH6PTTZxjnPXGp2Uhurw+2Ll4Hjg==",
"version": "1.4.763",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.763.tgz",
"integrity": "sha512-k4J8NrtJ9QrvHLRo8Q18OncqBCB7tIUyqxRcJnlonQ0ioHKYB988GcDFF3ZePmnb8eHEopDs/wPHR/iGAFgoUQ==",
"dev": true
},
"node_modules/emoji-regex": {
@ -2725,9 +2725,9 @@
}
},
"node_modules/eslint-plugin-svelte": {
"version": "2.38.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-svelte/-/eslint-plugin-svelte-2.38.0.tgz",
"integrity": "sha512-IwwxhHzitx3dr0/xo0z4jjDlb2AAHBPKt+juMyKKGTLlKi1rZfA4qixMwnveU20/JTHyipM6keX4Vr7LZFYc9g==",
"version": "2.39.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-svelte/-/eslint-plugin-svelte-2.39.0.tgz",
"integrity": "sha512-FXktBLXsrxbA+6ZvJK2z/sQOrUKyzSg3fNWK5h0reSCjr2fjAsc9ai/s/JvSl4Hgvz3nYVtTIMwarZH5RcB7BA==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
@ -2735,13 +2735,13 @@
"debug": "^4.3.4",
"eslint-compat-utils": "^0.5.0",
"esutils": "^2.0.3",
"known-css-properties": "^0.30.0",
"known-css-properties": "^0.31.0",
"postcss": "^8.4.38",
"postcss-load-config": "^3.1.4",
"postcss-safe-parser": "^6.0.0",
"postcss-selector-parser": "^6.0.16",
"semver": "^7.6.0",
"svelte-eslint-parser": ">=0.35.0 <1.0.0"
"svelte-eslint-parser": ">=0.36.0 <1.0.0"
},
"engines": {
"node": "^14.17.0 || >=16.0.0"
@ -3348,9 +3348,9 @@
}
},
"node_modules/get-tsconfig": {
"version": "4.7.4",
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.4.tgz",
"integrity": "sha512-ofbkKj+0pjXjhejr007J/fLf+sW+8H7K5GCm+msC8q3IpvgjobpyPqSRFemNyIMxklC0zeJpi7VDFna19FacvQ==",
"version": "4.7.5",
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.5.tgz",
"integrity": "sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==",
"dev": true,
"dependencies": {
"resolve-pkg-maps": "^1.0.0"
@ -4154,9 +4154,9 @@
}
},
"node_modules/known-css-properties": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.30.0.tgz",
"integrity": "sha512-VSWXYUnsPu9+WYKkfmJyLKtIvaRJi1kXUqVmBACORXZQxT5oZDsoZ2vQP+bQFDnWtpI/4eq3MLoRMjI2fnLzTQ==",
"version": "0.31.0",
"resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.31.0.tgz",
"integrity": "sha512-sBPIUGTNF0czz0mwGGUoKKJC8Q7On1GPbCSFPfyEsfHb2DyBG0Y4QtV+EVWpINSaiGKZblDNuF5AezxSgOhesQ==",
"dev": true
},
"node_modules/levn": {
@ -4359,9 +4359,9 @@
}
},
"node_modules/minipass": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.0.tgz",
"integrity": "sha512-oGZRv2OT1lO2UF1zUcwdTb3wqUwI0kBGTgt/T7OdSj6M6N5m3o5uPf0AIW6lVxGGoiWUR7e2AwTE+xiwK8WQig==",
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz",
"integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==",
"dev": true,
"engines": {
"node": ">=16 || 14 >=14.17"
@ -4797,16 +4797,16 @@
"dev": true
},
"node_modules/path-scurry": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.2.tgz",
"integrity": "sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==",
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
"integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
"dev": true,
"dependencies": {
"lru-cache": "^10.2.0",
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
},
"engines": {
"node": ">=16 || 14 >=14.17"
"node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@ -5636,9 +5636,9 @@
}
},
"node_modules/semver": {
"version": "7.6.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.1.tgz",
"integrity": "sha512-f/vbBsu+fOiYt+lmwZV0rVwJScl46HppnOA1ZvIuBWKOTlllpyJ3bfVax76/OrhCH38dyxoDIA8K7uB963IYgA==",
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz",
"integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==",
"dev": true,
"bin": {
"semver": "bin/semver.js"
@ -5963,22 +5963,22 @@
}
},
"node_modules/sucrase/node_modules/glob": {
"version": "10.3.12",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz",
"integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==",
"version": "10.3.15",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.15.tgz",
"integrity": "sha512-0c6RlJt1TICLyvJYIApxb8GsXoai0KUP7AxKKAtsYXdgJR1mGEUa7DgwShbdk1nly0PYoZj01xd4hzbq3fsjpw==",
"dev": true,
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^2.3.6",
"minimatch": "^9.0.1",
"minipass": "^7.0.4",
"path-scurry": "^1.10.2"
"path-scurry": "^1.11.0"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"engines": {
"node": ">=16 || 14 >=14.17"
"node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@ -6056,9 +6056,9 @@
}
},
"node_modules/svelte-eslint-parser": {
"version": "0.35.0",
"resolved": "https://registry.npmjs.org/svelte-eslint-parser/-/svelte-eslint-parser-0.35.0.tgz",
"integrity": "sha512-CtbPseajW0gjwEvHiuzYJkPDjAcHz2FaHt540j6RVYrZgnE6xWkzUBodQ4I3nV+G5AS0Svt8K6aIA/CIU9xT2Q==",
"version": "0.36.0",
"resolved": "https://registry.npmjs.org/svelte-eslint-parser/-/svelte-eslint-parser-0.36.0.tgz",
"integrity": "sha512-/6YmUSr0FAVxW8dXNdIMydBnddPMHzaHirAZ7RrT21XYdgGGZMh0LQG6CZsvAFS4r2Y4ItUuCQc8TQ3urB30mQ==",
"dev": true,
"dependencies": {
"eslint-scope": "^7.2.2",
@ -6074,7 +6074,7 @@
"url": "https://github.com/sponsors/ota-meshi"
},
"peerDependencies": {
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.112"
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.115"
},
"peerDependenciesMeta": {
"svelte": {
@ -6432,9 +6432,9 @@
"dev": true
},
"node_modules/tsx": {
"version": "4.9.3",
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.9.3.tgz",
"integrity": "sha512-czVbetlILiyJZI5zGlj2kw9vFiSeyra9liPD4nG+Thh4pKTi0AmMEQ8zdV/L2xbIVKrIqif4sUNrsMAOksx9Zg==",
"version": "4.10.1",
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.10.1.tgz",
"integrity": "sha512-G+CcyTOopwhuI81FU+KpzGN5UBhHgGEDlGt8mHAXKxv8pDGr6WI7hI7aRjTRol5WzFVsSNuzl3ekCZ0eLIJlEQ==",
"dev": true,
"dependencies": {
"esbuild": "~0.20.2",

View file

@ -68,7 +68,7 @@
"autoprefixer": "^10.4.7",
"daisyui": "^4.4.22",
"dotenv": "^16.0.1",
"eslint": "^8.16.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.28.0",
"fs-extra": "^11.1.0",

View file

@ -49,6 +49,7 @@ export {
type JorfTextelrNature,
type JorfTextelrOrigine,
type JorfTexteVersion,
type JorfTexteVersionLien,
type JorfTexteVersionLienNature,
type JorfTexteVersionLienType,
type JorfTexteVersionNature,
@ -80,6 +81,7 @@ export {
allLegiTexteVersionOrigines,
type LegiArticle,
type LegiArticleEtat,
type LegiArticleLien,
type LegiArticleLienArticleOrigine,
type LegiArticleLienNature,
type LegiArticleLienType,
@ -99,6 +101,7 @@ export {
type LegiTextelrOrigine,
type LegiTexteVersion,
type LegiTexteVersionEtat,
type LegiTexteVersionLien,
type LegiTexteVersionLienNature,
type LegiTexteVersionLienType,
type LegiTexteVersionNature,

View file

@ -338,7 +338,7 @@ export interface JorfTexteVersion {
export interface JorfTexteVersionLien {
"#text"?: string
"@cidtexte"?: string
"@cidtexte"?: string // Present if and only if @id is present
"@datesignatexte"?: string
"@id"?: string
"@naturetexte"?: JorfTexteVersionLienNature

View file

@ -68,7 +68,7 @@ export type LegiArticleEtat = (typeof allLegiArticleEtats)[number]
export interface LegiArticleLien {
"#text"?: string
"@cidtexte"?: string
"@cidtexte"?: string // Present if and only if @id is present
"@datesignatexte"?: string
"@id"?: string
"@naturetexte"?: LegiArticleLienNature
@ -320,7 +320,7 @@ export type LegiTexteVersionEtat = (typeof allLegiTexteVersionEtats)[number]
export interface LegiTexteVersionLien {
"#text"?: string
"@cidtexte"?: string
"@cidtexte"?: string // Present if and only if @id is present
"@datesignatexte"?: string
"@id"?: string
"@naturetexte"?: LegiTexteVersionLienNature

View file

@ -5,6 +5,7 @@ export const allSens = ["cible", "source"] as const
export interface ArticleLienDb {
article_id: string
cible: boolean
cidtexte: string | null
id: string
typelien: string
}
@ -12,6 +13,7 @@ export interface ArticleLienDb {
export interface TexteVersionLienDb {
texte_version_id: string
cible: boolean
cidtexte: string | null
id: string
typelien: string
}

View file

@ -1,11 +1,12 @@
import {
type Audit,
auditEmptyToNull,
auditInteger,
auditRequire,
auditStringToNumber,
auditTest,
auditTrimString,
cleanAudit,
type Audit,
} from "@auditors/core"
export function auditConfig(
@ -48,6 +49,7 @@ export function auditConfig(
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
@ -77,6 +79,7 @@ export function auditDb(
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
}

View file

@ -95,6 +95,15 @@ export async function configureDatabase() {
`
}
if (version.number < 10) {
await db`
DROP TABLE article_lien
`
await db`
DROP TABLE texte_version_lien
`
}
// Types
// Tables
@ -122,6 +131,7 @@ export async function configureDatabase() {
CREATE TABLE IF NOT EXISTS article_lien (
article_id char(20) NOT NULL REFERENCES article(id) ON DELETE CASCADE,
cible boolean,
cidtexte char(20),
id char(20) NOT NULL,
typelien text NOT NULL,
PRIMARY KEY (article_id, cible, typelien, id)
@ -196,6 +206,7 @@ export async function configureDatabase() {
CREATE TABLE IF NOT EXISTS texte_version_lien (
texte_version_id char(20) NOT NULL REFERENCES texte_version(id) ON DELETE CASCADE,
cible boolean,
cidtexte char(20),
id char(20) NOT NULL,
typelien text NOT NULL,
PRIMARY KEY (texte_version_id, cible, typelien, id)
@ -303,7 +314,11 @@ export async function configureDatabase() {
// `
await db`
CREATE INDEX IF NOT EXISTS article_lien_reverse_key
CREATE INDEX IF NOT EXISTS article_lien_cidtext_reverse_key
ON article_lien (cidtexte, cible, typelien)
`
await db`
CREATE INDEX IF NOT EXISTS article_lien_id_reverse_key
ON article_lien (id, cible, typelien)
`
@ -323,7 +338,12 @@ export async function configureDatabase() {
`
await db`
CREATE INDEX IF NOT EXISTS texte_version_lien_reverse_key
CREATE INDEX IF NOT EXISTS texte_version_lien_cidtext_reverse_key
ON texte_version_lien (cidtexte, cible, typelien)
`
await db`
CREATE INDEX IF NOT EXISTS texte_version_lien_id_reverse_key
ON texte_version_lien (id, cible, typelien)
`

View file

@ -23,7 +23,7 @@ export const db = postgres({
port: config.db.port,
user: config.db.user,
})
export const versionNumber = 9
export const versionNumber = 10
/// Check that assemblee database exists and is up to date.
export async function checkAssembleeDb(): Promise<void> {

View file

@ -36,11 +36,12 @@ async function indexLiens(): Promise<void> {
await db<
{
cible: boolean
cidtexte: string | null
id: string
typelien: LegiArticleLienType
}[]
>`
SELECT id, cible, typelien
SELECT cible, cidtexte, id, typelien
FROM article_lien
WHERE article_id = ${id}
`
@ -54,6 +55,7 @@ async function indexLiens(): Promise<void> {
existingLienByHash.delete(
objectHash({
cible: lien["@sens"] === "cible",
cidtexte: lien["@cidtexte"] ?? null,
id: lien["@id"],
typelien: lien["@typelien"],
}),
@ -62,11 +64,13 @@ async function indexLiens(): Promise<void> {
INSERT INTO article_lien (
article_id,
cible,
cidtexte,
id,
typelien
) VALUES (
${id},
${lien["@sens"] === "cible"},
${lien["@cidtexte"] ?? null},
${lien["@id"]},
${lien["@typelien"]}
)
@ -77,6 +81,7 @@ async function indexLiens(): Promise<void> {
for (const {
cible,
cidtexte,
id: linkedId,
typelien,
} of existingLienByHash.values()) {
@ -85,6 +90,7 @@ async function indexLiens(): Promise<void> {
WHERE
article_id = ${id}
AND cible = ${cible}
AND cidtexte = ${cidtexte}
AND id = ${linkedId}
AND typelien = ${typelien}
`
@ -114,6 +120,7 @@ async function indexLiens(): Promise<void> {
await db<
{
cible: boolean
cidtexte: string | null
id: string
typelien: JorfTexteVersionLienType | LegiTexteVersionLienType
}[]
@ -132,6 +139,7 @@ async function indexLiens(): Promise<void> {
existingLienByHash.delete(
objectHash({
cible: lien["@sens"] === "cible",
cidtexte: lien["@cidtexte"] ?? null,
id: lien["@id"],
typelien: lien["@typelien"],
}),
@ -140,11 +148,13 @@ async function indexLiens(): Promise<void> {
INSERT INTO texte_version_lien (
texte_version_id,
cible,
cidtexte,
id,
typelien
) VALUES (
${id},
${lien["@sens"] === "cible"},
${lien["@cidtexte"] ?? null},
${lien["@id"]},
${lien["@typelien"]}
)
@ -155,6 +165,7 @@ async function indexLiens(): Promise<void> {
for (const {
cible,
cidtexte,
id: linkedId,
typelien,
} of existingLienByHash.values()) {
@ -163,6 +174,7 @@ async function indexLiens(): Promise<void> {
WHERE
texte_version_id_id = ${id}
AND cible = ${cible}
AND cidtexte = ${cidtexte}
AND id = ${linkedId}
AND typelien = ${typelien}
`