@tricoteuses/senat 2.16.4 → 2.16.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/loaders.d.ts +2 -0
- package/lib/model/agenda.d.ts +4 -0
- package/lib/model/agenda.js +27 -8
- package/lib/model/debats.d.ts +26 -2
- package/lib/model/debats.js +65 -57
- package/lib/model/documents.js +4 -8
- package/lib/model/dosleg.d.ts +0 -13
- package/lib/model/dosleg.js +0 -13
- package/lib/model/index.d.ts +1 -1
- package/lib/model/index.js +1 -1
- package/lib/scripts/convert_data.js +52 -56
- package/lib/scripts/retrieve_documents.js +43 -10
- package/lib/scripts/retrieve_open_data.js +2 -6
- package/lib/scripts/retrieve_videos.d.ts +1 -5
- package/lib/scripts/retrieve_videos.js +124 -111
- package/lib/scripts/shared/cli_helpers.d.ts +5 -0
- package/lib/scripts/shared/cli_helpers.js +6 -7
- package/package.json +2 -1
- package/lib/model/compte_rendu.d.ts +0 -9
- package/lib/model/compte_rendu.js +0 -325
- package/lib/raw_types/db.d.ts +0 -11389
- package/lib/raw_types/db.js +0 -5
- package/lib/scripts/retrieve_comptes_rendus.d.ts +0 -6
- package/lib/scripts/retrieve_comptes_rendus.js +0 -274
package/lib/loaders.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type IterItem<T> = {
|
|
|
29
29
|
export interface TexteMetadata {
|
|
30
30
|
name: string;
|
|
31
31
|
session: number | null | undefined;
|
|
32
|
+
date?: string | null;
|
|
32
33
|
url_expose_des_motifs?: URL;
|
|
33
34
|
url_xml: URL;
|
|
34
35
|
url_html: URL;
|
|
@@ -37,6 +38,7 @@ export interface TexteMetadata {
|
|
|
37
38
|
export interface RapportMetadata {
|
|
38
39
|
name: string;
|
|
39
40
|
session: number | null | undefined;
|
|
41
|
+
date?: string | null;
|
|
40
42
|
url_html: URL;
|
|
41
43
|
url_pdf: URL;
|
|
42
44
|
}
|
package/lib/model/agenda.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { AgendaEvent } from "../types/agenda";
|
|
2
|
+
export declare function getStartAndEndTimes(timeStr: string | null | undefined, dateISO: string): {
|
|
3
|
+
startTime: string | null;
|
|
4
|
+
endTime: string | null;
|
|
5
|
+
};
|
|
2
6
|
export declare function parseAgendaFromFile(htmlFilePath: string): Promise<AgendaEvent[] | null>;
|
package/lib/model/agenda.js
CHANGED
|
@@ -64,18 +64,37 @@ function normalizeTime(timeStr) {
|
|
|
64
64
|
?.replace(/\s\(hors hémicycle\)/i, "")
|
|
65
65
|
?.replace(/\s*h\s*/gi, "h");
|
|
66
66
|
}
|
|
67
|
-
function getStartAndEndTimes(timeStr) {
|
|
67
|
+
export function getStartAndEndTimes(timeStr, dateISO) {
|
|
68
68
|
const normalizedTime = normalizeTime(timeStr);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if (!normalizedTime) {
|
|
70
|
+
return { startTime: null, endTime: null };
|
|
71
|
+
}
|
|
72
|
+
const rangeMatch = normalizedTime.match(/^de (?<start>\d{1,2}h\d{2}) à (?<end>\d{1,2}h\d{2})$/i);
|
|
73
|
+
const toUtcIso = (value) => {
|
|
74
|
+
if (!value)
|
|
75
|
+
return null;
|
|
76
|
+
const time = DateTime.fromFormat(value, "H'h'mm", { zone: FR_TZ });
|
|
77
|
+
if (!time.isValid)
|
|
78
|
+
return null;
|
|
79
|
+
const local = DateTime.fromISO(dateISO, { zone: FR_TZ }).set({
|
|
80
|
+
hour: time.hour,
|
|
81
|
+
minute: time.minute,
|
|
82
|
+
second: 0,
|
|
83
|
+
millisecond: 0,
|
|
84
|
+
});
|
|
85
|
+
if (!local.isValid)
|
|
86
|
+
return null;
|
|
87
|
+
return local.toUTC().toISO();
|
|
88
|
+
};
|
|
89
|
+
if (rangeMatch?.groups) {
|
|
90
|
+
const { start, end } = rangeMatch.groups;
|
|
72
91
|
return {
|
|
73
|
-
startTime:
|
|
74
|
-
endTime:
|
|
92
|
+
startTime: toUtcIso(start),
|
|
93
|
+
endTime: toUtcIso(end),
|
|
75
94
|
};
|
|
76
95
|
}
|
|
77
96
|
return {
|
|
78
|
-
startTime:
|
|
97
|
+
startTime: toUtcIso(normalizedTime),
|
|
79
98
|
endTime: null,
|
|
80
99
|
};
|
|
81
100
|
}
|
|
@@ -91,7 +110,7 @@ function transformAgenda(document, fileName) {
|
|
|
91
110
|
const type = getEventType(eventElement.classList);
|
|
92
111
|
const date = DateTime.fromFormat(fileName, ID_DATE_FORMAT).toFormat(STANDARD_DATE_FORMAT);
|
|
93
112
|
const timeOriginal = eventElement.querySelector(".time")?.textContent || null;
|
|
94
|
-
const { startTime, endTime } = getStartAndEndTimes(timeOriginal);
|
|
113
|
+
const { startTime, endTime } = getStartAndEndTimes(timeOriginal, date);
|
|
95
114
|
const titre = eventElement.querySelector(".titre")?.textContent?.trim() || "";
|
|
96
115
|
const organe = eventElement.querySelector(".organe")?.textContent?.trim() || null;
|
|
97
116
|
const objet = eventElement.querySelector(".objet")?.textContent?.trim()?.replace(/^- /, "") || null;
|
package/lib/model/debats.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InferResult } from "kysely";
|
|
2
2
|
export type DebatResult = InferResult<typeof findAllQuery>[0];
|
|
3
|
-
declare const findAllQuery: import("kysely").SelectQueryBuilder<any, "debats", {
|
|
3
|
+
declare const findAllQuery: import("kysely").SelectQueryBuilder<any, "debats.debats", {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
id: string;
|
|
6
6
|
date_seance: string;
|
|
@@ -8,19 +8,31 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<any, "debats", {
|
|
|
8
8
|
[x: string]: any;
|
|
9
9
|
interventions: {
|
|
10
10
|
[x: string]: any;
|
|
11
|
+
auteur: {
|
|
12
|
+
code: any;
|
|
13
|
+
nom: any;
|
|
14
|
+
prenom: any;
|
|
15
|
+
matricule: any;
|
|
16
|
+
};
|
|
11
17
|
}[];
|
|
12
18
|
}[];
|
|
13
19
|
sections_divers: {
|
|
14
20
|
[x: string]: any;
|
|
15
21
|
interventions: {
|
|
16
22
|
[x: string]: any;
|
|
23
|
+
auteur: {
|
|
24
|
+
code: any;
|
|
25
|
+
nom: any;
|
|
26
|
+
prenom: any;
|
|
27
|
+
matricule: any;
|
|
28
|
+
};
|
|
17
29
|
}[];
|
|
18
30
|
}[];
|
|
19
31
|
lectures: {
|
|
20
32
|
id: any;
|
|
21
33
|
}[];
|
|
22
34
|
}>;
|
|
23
|
-
export declare function findAll(): AsyncIterableIterator<{
|
|
35
|
+
export declare function findAll(fromSession?: number): AsyncIterableIterator<{
|
|
24
36
|
[x: string]: any;
|
|
25
37
|
id: string;
|
|
26
38
|
date_seance: string;
|
|
@@ -28,12 +40,24 @@ export declare function findAll(): AsyncIterableIterator<{
|
|
|
28
40
|
[x: string]: any;
|
|
29
41
|
interventions: {
|
|
30
42
|
[x: string]: any;
|
|
43
|
+
auteur: {
|
|
44
|
+
code: any;
|
|
45
|
+
nom: any;
|
|
46
|
+
prenom: any;
|
|
47
|
+
matricule: any;
|
|
48
|
+
};
|
|
31
49
|
}[];
|
|
32
50
|
}[];
|
|
33
51
|
sections_divers: {
|
|
34
52
|
[x: string]: any;
|
|
35
53
|
interventions: {
|
|
36
54
|
[x: string]: any;
|
|
55
|
+
auteur: {
|
|
56
|
+
code: any;
|
|
57
|
+
nom: any;
|
|
58
|
+
prenom: any;
|
|
59
|
+
matricule: any;
|
|
60
|
+
};
|
|
37
61
|
}[];
|
|
38
62
|
}[];
|
|
39
63
|
lectures: {
|
package/lib/model/debats.js
CHANGED
|
@@ -1,87 +1,95 @@
|
|
|
1
|
-
import { jsonArrayFrom } from "kysely/helpers/postgres";
|
|
1
|
+
import { jsonArrayFrom, jsonBuildObject } from "kysely/helpers/postgres";
|
|
2
2
|
import { dbSenat } from "../databases";
|
|
3
3
|
import { ID_DATE_FORMAT } from "../scripts/datautil";
|
|
4
4
|
import { toDateString } from "./util";
|
|
5
5
|
function sectionsLegislatives(dateSeance) {
|
|
6
6
|
return jsonArrayFrom(dbSenat
|
|
7
|
-
.
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
.where("secdis.datsea", "=", dateSeance)
|
|
7
|
+
.selectFrom("debats.secdis")
|
|
8
|
+
.leftJoin("debats.typsec", "debats.secdis.typseccod", "debats.typsec.typseccod")
|
|
9
|
+
.where("debats.secdis.datsea", "=", dateSeance)
|
|
11
10
|
.select(({ ref }) => [
|
|
12
|
-
"secdis.secdisordid as id",
|
|
13
|
-
"secdis.secdisnum as numero",
|
|
14
|
-
"secdis.secdisobj as objet",
|
|
15
|
-
"secdis.secdisurl as url",
|
|
16
|
-
"typsec.typseclib as type",
|
|
17
|
-
"typsec.typseccat as categorie",
|
|
18
|
-
interventionsLegislatives(ref("secdis.secdiscle")).as("interventions"),
|
|
19
|
-
"secdis.lecassidt as lecture_id"
|
|
11
|
+
"debats.secdis.secdisordid as id",
|
|
12
|
+
"debats.secdis.secdisnum as numero",
|
|
13
|
+
"debats.secdis.secdisobj as objet",
|
|
14
|
+
"debats.secdis.secdisurl as url",
|
|
15
|
+
"debats.typsec.typseclib as type",
|
|
16
|
+
"debats.typsec.typseccat as categorie",
|
|
17
|
+
interventionsLegislatives(ref("debats.secdis.secdiscle")).as("interventions"),
|
|
18
|
+
"debats.secdis.lecassidt as lecture_id"
|
|
20
19
|
])
|
|
21
|
-
.orderBy("secdis.secdisordid asc"));
|
|
20
|
+
.orderBy("debats.secdis.secdisordid asc"));
|
|
22
21
|
}
|
|
23
22
|
function interventionsLegislatives(sectionId) {
|
|
24
23
|
return jsonArrayFrom(dbSenat
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.where("intpjl.secdiscle", "=", sectionId)
|
|
28
|
-
.select(({ ref, val }) => [
|
|
29
|
-
"intpjl.intordid as id",
|
|
30
|
-
"intpjl.autcod as auteur_code",
|
|
31
|
-
"intpjl.intfon as fonction_intervenant",
|
|
32
|
-
"intpjl.inturl as url",
|
|
33
|
-
"intpjl.intana as analyse",
|
|
24
|
+
.selectFrom("debats.intpjl")
|
|
25
|
+
.leftJoin("dosleg.auteur", "debats.intpjl.autcod", "dosleg.auteur.autcod")
|
|
26
|
+
.where("debats.intpjl.secdiscle", "=", sectionId)
|
|
27
|
+
.select(({ ref, val, fn }) => [
|
|
28
|
+
"debats.intpjl.intordid as id",
|
|
29
|
+
"debats.intpjl.autcod as auteur_code",
|
|
30
|
+
"debats.intpjl.intfon as fonction_intervenant",
|
|
31
|
+
"debats.intpjl.inturl as url",
|
|
32
|
+
"debats.intpjl.intana as analyse",
|
|
33
|
+
jsonBuildObject({
|
|
34
|
+
code: ref("dosleg.auteur.autcod"),
|
|
35
|
+
nom: ref("dosleg.auteur.nomuse"),
|
|
36
|
+
prenom: ref("dosleg.auteur.prenom"),
|
|
37
|
+
matricule: ref("dosleg.auteur.autmat")
|
|
38
|
+
}).as("auteur")
|
|
34
39
|
])
|
|
35
|
-
.orderBy("intpjl.intordid asc"));
|
|
40
|
+
.orderBy("debats.intpjl.intordid asc"));
|
|
36
41
|
}
|
|
37
42
|
function sectionsNonLegislatives(dateSeance) {
|
|
38
43
|
return jsonArrayFrom(dbSenat
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
.where("secdivers.datsea", "=", dateSeance)
|
|
44
|
+
.selectFrom("debats.secdivers")
|
|
45
|
+
.leftJoin("debats.typsec", "debats.secdivers.typseccod", "debats.typsec.typseccod")
|
|
46
|
+
.where("debats.secdivers.datsea", "=", dateSeance)
|
|
43
47
|
.select(({ ref }) => [
|
|
44
|
-
"secdivers.secdiverslibelle as libelle",
|
|
45
|
-
"secdivers.secdiversobj as objet",
|
|
46
|
-
"typsec.typseclib as type",
|
|
47
|
-
"typsec.typseccat as categorie",
|
|
48
|
-
interventionsNonLegislatives(ref("secdivers.secdiverscle")).as("interventions"),
|
|
48
|
+
"debats.secdivers.secdiverslibelle as libelle",
|
|
49
|
+
"debats.secdivers.secdiversobj as objet",
|
|
50
|
+
"debats.typsec.typseclib as type",
|
|
51
|
+
"debats.typsec.typseccat as categorie",
|
|
52
|
+
interventionsNonLegislatives(ref("debats.secdivers.secdiverscle")).as("interventions"),
|
|
49
53
|
]));
|
|
50
54
|
}
|
|
51
55
|
function interventionsNonLegislatives(sectionId) {
|
|
52
56
|
return jsonArrayFrom(dbSenat
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.where("intdivers.intdiverscle", "=", sectionId)
|
|
57
|
+
.selectFrom("debats.intdivers")
|
|
58
|
+
.leftJoin("dosleg.auteur", "debats.intdivers.autcod", "dosleg.auteur.autcod")
|
|
59
|
+
.where("debats.intdivers.intdiverscle", "=", sectionId)
|
|
56
60
|
.select(({ ref, val }) => [
|
|
57
|
-
"intdivers.intdiversordid as id",
|
|
58
|
-
"intdivers.autcod as auteur_code",
|
|
59
|
-
"intdivers.intfon as fonction_intervenant",
|
|
60
|
-
"intdivers.inturl as url",
|
|
61
|
-
"intdivers.intana as analyse",
|
|
61
|
+
"debats.intdivers.intdiversordid as id",
|
|
62
|
+
"debats.intdivers.autcod as auteur_code",
|
|
63
|
+
"debats.intdivers.intfon as fonction_intervenant",
|
|
64
|
+
"debats.intdivers.inturl as url",
|
|
65
|
+
"debats.intdivers.intana as analyse",
|
|
66
|
+
jsonBuildObject({
|
|
67
|
+
code: ref("dosleg.auteur.autcod"),
|
|
68
|
+
nom: ref("dosleg.auteur.nomuse"),
|
|
69
|
+
prenom: ref("dosleg.auteur.prenom"),
|
|
70
|
+
matricule: ref("dosleg.auteur.autmat")
|
|
71
|
+
}).as("auteur")
|
|
62
72
|
])
|
|
63
|
-
.orderBy("intdivers.intdiversordid asc"));
|
|
73
|
+
.orderBy("debats.intdivers.intdiversordid asc"));
|
|
64
74
|
}
|
|
65
75
|
function lecturesAssemblee(dateSeance) {
|
|
66
76
|
return jsonArrayFrom(dbSenat
|
|
67
|
-
.
|
|
68
|
-
.
|
|
69
|
-
.
|
|
70
|
-
.select("lecassdeb.lecassidt as id"));
|
|
77
|
+
.selectFrom("debats.lecassdeb")
|
|
78
|
+
.where("debats.lecassdeb.datsea", "=", dateSeance)
|
|
79
|
+
.select("debats.lecassdeb.lecassidt as id"));
|
|
71
80
|
}
|
|
72
81
|
const findAllQuery = dbSenat
|
|
73
|
-
.
|
|
74
|
-
.selectFrom("debats")
|
|
82
|
+
.selectFrom("debats.debats")
|
|
75
83
|
.select(({ ref, val }) => [
|
|
76
|
-
toDateString(ref("debats.datsea"), val(ID_DATE_FORMAT)).as("id"),
|
|
77
|
-
toDateString(ref("debats.datsea")).as("date_seance"),
|
|
78
|
-
"debats.numero as numero",
|
|
79
|
-
"debats.deburl as url",
|
|
80
|
-
"debats.debsyn as etat_synchronisation",
|
|
81
|
-
sectionsLegislatives(ref("debats.datsea")).as("sections"),
|
|
82
|
-
sectionsNonLegislatives(ref("debats.datsea")).as("sections_divers"),
|
|
83
|
-
lecturesAssemblee(ref("debats.datsea")).as("lectures"),
|
|
84
|
+
toDateString(ref("debats.debats.datsea"), val(ID_DATE_FORMAT)).as("id"),
|
|
85
|
+
toDateString(ref("debats.debats.datsea")).as("date_seance"),
|
|
86
|
+
"debats.debats.numero as numero",
|
|
87
|
+
"debats.debats.deburl as url",
|
|
88
|
+
"debats.debats.debsyn as etat_synchronisation",
|
|
89
|
+
sectionsLegislatives(ref("debats.debats.datsea")).as("sections"),
|
|
90
|
+
sectionsNonLegislatives(ref("debats.debats.datsea")).as("sections_divers"),
|
|
91
|
+
lecturesAssemblee(ref("debats.debats.datsea")).as("lectures"),
|
|
84
92
|
]);
|
|
85
|
-
export function findAll() {
|
|
93
|
+
export function findAll(fromSession) {
|
|
86
94
|
return findAllQuery.stream();
|
|
87
95
|
}
|
package/lib/model/documents.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dbSenat } from "../databases";
|
|
2
|
-
import { rtrim } from "./util";
|
|
2
|
+
import { rtrim, toDateString } from "./util";
|
|
3
3
|
export function findSenatTexteUrls(sessions = []) {
|
|
4
4
|
return dbSenat
|
|
5
5
|
.withSchema("dosleg")
|
|
@@ -10,13 +10,8 @@ export function findSenatTexteUrls(sessions = []) {
|
|
|
10
10
|
.select(({ eb, ref }) => [
|
|
11
11
|
"sesann as session",
|
|
12
12
|
rtrim(ref("texurl")).as("url"),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.when("oritxtcod", "=", "1")
|
|
16
|
-
.then(true)
|
|
17
|
-
.else(false)
|
|
18
|
-
.end()
|
|
19
|
-
.as("hasExposeDesMotifs"),
|
|
13
|
+
toDateString(ref("txtoritxtdat")).as("date"),
|
|
14
|
+
eb.case().when("oritxtcod", "=", "1").then(true).else(false).end().as("hasExposeDesMotifs"),
|
|
20
15
|
])
|
|
21
16
|
.$narrowType()
|
|
22
17
|
.stream();
|
|
@@ -31,6 +26,7 @@ export function findSenatRapportUrls(sessions = []) {
|
|
|
31
26
|
.select(({ ref }) => [
|
|
32
27
|
"sesann as session",
|
|
33
28
|
rtrim(ref("rapurl")).as("url"),
|
|
29
|
+
toDateString(ref("date_depot")).as("date"),
|
|
34
30
|
])
|
|
35
31
|
.$narrowType()
|
|
36
32
|
.stream();
|
package/lib/model/dosleg.d.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { InferResult, SelectQueryBuilder } from "kysely";
|
|
2
2
|
declare const findAllDossiersQuery: SelectQueryBuilder<any, any, any>;
|
|
3
3
|
export declare function findAllDossiers(): AsyncIterableIterator<DossierLegislatifResult>;
|
|
4
|
-
declare const findAuteursQuery: SelectQueryBuilder<any, "dosleg.auteur", {
|
|
5
|
-
code: any;
|
|
6
|
-
nom: any;
|
|
7
|
-
prenom: any;
|
|
8
|
-
matricule: any;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function findAuteurs(): Promise<{
|
|
11
|
-
code: any;
|
|
12
|
-
nom: any;
|
|
13
|
-
prenom: any;
|
|
14
|
-
matricule: any;
|
|
15
|
-
}[]>;
|
|
16
4
|
export declare function createActesLegislatifs(dossier: DossierLegislatifResult): any;
|
|
17
5
|
export declare function getCodeActeLecture(codeNatureDossier: string, typeLecture: string, assemblee: string): string | null;
|
|
18
6
|
export declare function getCodeActeTexte(codeParent: string | null, texteOrigine: string): string | null;
|
|
19
7
|
export type DossierLegislatifResult = InferResult<typeof findAllDossiersQuery>[0];
|
|
20
|
-
export type AuteurResult = InferResult<typeof findAuteursQuery>[0];
|
|
21
8
|
export {};
|
package/lib/model/dosleg.js
CHANGED
|
@@ -222,19 +222,6 @@ const findAllDossiersQuery = dbSenat
|
|
|
222
222
|
export function findAllDossiers() {
|
|
223
223
|
return findAllDossiersQuery.stream();
|
|
224
224
|
}
|
|
225
|
-
const findAuteursQuery = dbSenat
|
|
226
|
-
.withSchema("dosleg")
|
|
227
|
-
.selectFrom("dosleg.auteur")
|
|
228
|
-
.select([
|
|
229
|
-
"autcod as code",
|
|
230
|
-
"nomuse as nom",
|
|
231
|
-
"prenom as prenom",
|
|
232
|
-
"autmat as matricule",
|
|
233
|
-
]);
|
|
234
|
-
export async function findAuteurs() {
|
|
235
|
-
return findAuteursQuery
|
|
236
|
-
.execute();
|
|
237
|
-
}
|
|
238
225
|
export function createActesLegislatifs(dossier) {
|
|
239
226
|
const actesLegislatifs = (dossier["lectures"] || []).map((lecture) => {
|
|
240
227
|
const lecturesAssemblee = (lecture["lectures_assemblee"] || []).map((lectureAss) => {
|
package/lib/model/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { findAllAmendements } from "./ameli";
|
|
2
2
|
export { findAll as findAllDebats } from "./debats";
|
|
3
|
-
export { findAllDossiers,
|
|
3
|
+
export { findAllDossiers, } from "./dosleg";
|
|
4
4
|
export { findSenatTexteUrls, findSenatRapportUrls } from "./documents";
|
|
5
5
|
export { findAllScrutins } from "./scrutins";
|
|
6
6
|
export { findAll as findAllQuestions } from "./questions";
|
package/lib/model/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { findAllAmendements } from "./ameli";
|
|
2
2
|
export { findAll as findAllDebats } from "./debats";
|
|
3
|
-
export { findAllDossiers,
|
|
3
|
+
export { findAllDossiers, } from "./dosleg";
|
|
4
4
|
export { findSenatTexteUrls, findSenatRapportUrls } from "./documents";
|
|
5
5
|
export { findAllScrutins } from "./scrutins";
|
|
6
6
|
export { findAll as findAllQuestions } from "./questions";
|
|
@@ -2,14 +2,15 @@ import assert from "assert";
|
|
|
2
2
|
import commandLineArgs from "command-line-args";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
import path from "path";
|
|
5
|
+
import pLimit from "p-limit";
|
|
5
6
|
import { datasets, EnabledDatasets, getEnabledDatasets } from "../datasets";
|
|
6
7
|
import { DATA_ORIGINAL_FOLDER, DOCUMENT_METADATA_FILE, DOSLEG_DOSSIERS_FOLDER, SCRUTINS_FOLDER, RAPPORT_FOLDER, SENS_CIRCONSCRIPTIONS_FOLDER, SENS_ORGANISMES_FOLDER, SENS_SENATEURS_FOLDER, TEXTE_FOLDER, } from "../loaders";
|
|
7
|
-
import { findAllAmendements, findAllCirconscriptions, findAllDebats, findAllDossiers, findAllScrutins, findAllOrganismes, findAllQuestions, findAllSens,
|
|
8
|
+
import { findAllAmendements, findAllCirconscriptions, findAllDebats, findAllDossiers, findAllScrutins, findAllOrganismes, findAllQuestions, findAllSens, findSenatRapportUrls, findSenatTexteUrls, } from "../model";
|
|
8
9
|
import { createActesLegislatifs } from "../model/dosleg";
|
|
9
10
|
import { UNDEFINED_SESSION } from "../types/sessions";
|
|
10
11
|
import { getSessionFromDate, getSessionFromSignet } from "./datautil";
|
|
11
12
|
import { commonOptions } from "./shared/cli_helpers";
|
|
12
|
-
import { ensureAndClearDir
|
|
13
|
+
import { ensureAndClearDir } from "./shared/util";
|
|
13
14
|
const optionsDefinitions = [...commonOptions];
|
|
14
15
|
const options = commandLineArgs(optionsDefinitions);
|
|
15
16
|
const SENAT_TEXTE_XML_BASE_URL = "https://www.senat.fr/akomantoso/";
|
|
@@ -47,19 +48,24 @@ async function convertDatasetAmeli(dataDir, options) {
|
|
|
47
48
|
console.log(`Converting database ${dataset.database} data into files…`);
|
|
48
49
|
}
|
|
49
50
|
const ameliReorganizedRootDir = path.join(dataDir, dataset.database);
|
|
50
|
-
|
|
51
|
+
await fs.ensureDir(ameliReorganizedRootDir);
|
|
52
|
+
const limit = pLimit(10);
|
|
53
|
+
const tasks = [];
|
|
51
54
|
for await (const amendement of findAllAmendements(options["fromSession"])) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
tasks.push(limit(async () => {
|
|
56
|
+
if (options["verbose"]) {
|
|
57
|
+
console.log(`Converting ${amendement["numero"]} file…`);
|
|
58
|
+
}
|
|
59
|
+
const session = String(amendement["session"]) || UNDEFINED_SESSION;
|
|
60
|
+
const signetDossierLegislatif = amendement["signet_dossier_legislatif"] ||
|
|
61
|
+
`${amendement["nature_texte"]}-${amendement["numero_texte"]}`.toLowerCase();
|
|
62
|
+
const ameliReorganizedDir = path.join(ameliReorganizedRootDir, String(session), signetDossierLegislatif);
|
|
63
|
+
await fs.ensureDir(ameliReorganizedDir);
|
|
64
|
+
const amendementFileName = `${amendement["numero"]}.json`;
|
|
65
|
+
await fs.writeJSON(path.join(ameliReorganizedDir, amendementFileName), amendement, { spaces: 2 });
|
|
66
|
+
}));
|
|
62
67
|
}
|
|
68
|
+
await Promise.all(tasks);
|
|
63
69
|
}
|
|
64
70
|
async function convertDatasetDebats(dataDir, options) {
|
|
65
71
|
const dataset = datasets.debats;
|
|
@@ -68,40 +74,19 @@ async function convertDatasetDebats(dataDir, options) {
|
|
|
68
74
|
}
|
|
69
75
|
const debatsReorganizedRootDir = path.join(dataDir, dataset.database);
|
|
70
76
|
ensureAndClearDir(debatsReorganizedRootDir);
|
|
71
|
-
const allAuteurs = await findAuteurs();
|
|
72
77
|
for await (const debat of findAllDebats()) {
|
|
73
78
|
if (options["verbose"]) {
|
|
74
79
|
console.log(`Converting ${debat.id} file…`);
|
|
75
80
|
}
|
|
76
|
-
const
|
|
77
|
-
const session = getSessionFromDate(enrichedDebat.date_seance);
|
|
81
|
+
const session = getSessionFromDate(debat.date_seance);
|
|
78
82
|
if (options["fromSession"] && session < options["fromSession"]) {
|
|
79
83
|
continue;
|
|
80
84
|
}
|
|
81
85
|
const debatsReorganizedDir = path.join(debatsReorganizedRootDir, String(session));
|
|
82
86
|
fs.ensureDirSync(debatsReorganizedDir);
|
|
83
|
-
const debatFileName = `${
|
|
84
|
-
fs.writeJSONSync(path.join(debatsReorganizedDir, debatFileName),
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async function enrichDebat(debat, auteurs) {
|
|
88
|
-
const enrichedDebat = { ...debat };
|
|
89
|
-
for (const section of enrichedDebat.sections) {
|
|
90
|
-
for (const intervention of section.interventions) {
|
|
91
|
-
;
|
|
92
|
-
intervention.auteur = findAuteur(intervention["auteur_code"], auteurs);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
for (const section of enrichedDebat.sections_divers) {
|
|
96
|
-
for (const intervention of section.interventions) {
|
|
97
|
-
;
|
|
98
|
-
intervention.auteur = findAuteur(intervention["auteur_code"], auteurs);
|
|
99
|
-
}
|
|
87
|
+
const debatFileName = `${debat.id}.json`;
|
|
88
|
+
fs.writeJSONSync(path.join(debatsReorganizedDir, debatFileName), debat, { spaces: 2 });
|
|
100
89
|
}
|
|
101
|
-
return enrichedDebat;
|
|
102
|
-
}
|
|
103
|
-
function findAuteur(auteurCode, auteurs) {
|
|
104
|
-
return auteurs.find((auteur) => auteur.code === auteurCode);
|
|
105
90
|
}
|
|
106
91
|
async function convertDatasetDosLeg(dataDir, options) {
|
|
107
92
|
const dataset = datasets.dosleg;
|
|
@@ -141,18 +126,22 @@ async function convertDatasetScrutins(dataDir, options) {
|
|
|
141
126
|
}
|
|
142
127
|
const scrutinsReorganizedDir = path.join(dataDir, SCRUTINS_FOLDER);
|
|
143
128
|
ensureAndClearDir(scrutinsReorganizedDir);
|
|
129
|
+
const limit = pLimit(10);
|
|
130
|
+
const tasks = [];
|
|
144
131
|
for await (const scrutin of findAllScrutins(options["fromSession"])) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
132
|
+
tasks.push(limit(async () => {
|
|
133
|
+
if (options["verbose"]) {
|
|
134
|
+
console.log(`Converting ${scrutin["numero"]} file…`);
|
|
135
|
+
}
|
|
136
|
+
let scrutinReorganizedDir = path.join(scrutinsReorganizedDir, String(UNDEFINED_SESSION));
|
|
137
|
+
const session = scrutin["session"] || UNDEFINED_SESSION;
|
|
138
|
+
scrutinReorganizedDir = path.join(scrutinsReorganizedDir, String(session));
|
|
139
|
+
await fs.ensureDir(scrutinReorganizedDir);
|
|
140
|
+
const scrutinFileName = `${scrutin["numero"]}.json`;
|
|
141
|
+
await fs.writeJSON(path.join(scrutinReorganizedDir, scrutinFileName), scrutin, {
|
|
142
|
+
spaces: 2,
|
|
143
|
+
});
|
|
144
|
+
}));
|
|
156
145
|
}
|
|
157
146
|
}
|
|
158
147
|
async function convertDatasetQuestions(dataDir) {
|
|
@@ -162,16 +151,21 @@ async function convertDatasetQuestions(dataDir) {
|
|
|
162
151
|
}
|
|
163
152
|
const questionsReorganizedRootDir = path.join(dataDir, dataset.database);
|
|
164
153
|
ensureAndClearDir(questionsReorganizedRootDir);
|
|
154
|
+
const limit = pLimit(10);
|
|
155
|
+
const tasks = [];
|
|
165
156
|
for await (const question of findAllQuestions()) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
157
|
+
tasks.push(limit(async () => {
|
|
158
|
+
if (options["verbose"]) {
|
|
159
|
+
console.log(`Converting ${question["reference"]} file…`);
|
|
160
|
+
}
|
|
161
|
+
const legislature = question["legislature"] ? question["legislature"] : 0;
|
|
162
|
+
const questionReorganizedDir = path.join(questionsReorganizedRootDir, String(legislature));
|
|
163
|
+
await fs.ensureDir(questionReorganizedDir);
|
|
164
|
+
const questionFileName = `${question["reference"]}.json`;
|
|
165
|
+
await fs.writeJSON(path.join(questionReorganizedDir, questionFileName), question, { spaces: 2 });
|
|
166
|
+
}));
|
|
174
167
|
}
|
|
168
|
+
await Promise.all(tasks);
|
|
175
169
|
}
|
|
176
170
|
async function convertTexteUrls(dataDir) {
|
|
177
171
|
const textesDir = path.join(dataDir, TEXTE_FOLDER);
|
|
@@ -184,6 +178,7 @@ async function convertTexteUrls(dataDir) {
|
|
|
184
178
|
const metadata = {
|
|
185
179
|
name: texteName,
|
|
186
180
|
session: texte.session,
|
|
181
|
+
date: texte.date,
|
|
187
182
|
url_expose_des_motifs: texte.hasExposeDesMotifs
|
|
188
183
|
? new URL(`${texteName}-expose.html`, SENAT_EXPOSE_DES_MOTIFS_BASE_URL)
|
|
189
184
|
: undefined,
|
|
@@ -218,6 +213,7 @@ async function convertRapportUrls(dataDir) {
|
|
|
218
213
|
const metadata = {
|
|
219
214
|
name: rapportName,
|
|
220
215
|
session: rapport.session,
|
|
216
|
+
date: rapport.date,
|
|
221
217
|
url_html: new URL(rapportHtmlUrl, SENAT_RAPPORT_BASE_URL),
|
|
222
218
|
url_pdf: new URL(rapportPdfUrl, SENAT_RAPPORT_BASE_URL),
|
|
223
219
|
};
|