@tricoteuses/senat 2.20.9 → 2.20.12
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/README.md +2 -2
- package/lib/model/ameli.js +1 -1
- package/lib/model/dosleg.js +3 -0
- package/lib/scripts/retrieve_cr_commission.js +10 -3
- package/lib/scripts/retrieve_open_data.js +10 -4
- package/lib/scripts/shared/cli_helpers.d.ts +7 -3
- package/lib/scripts/shared/cli_helpers.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,10 +56,10 @@ npm run data:parse_textes_lois ../senat-data
|
|
|
56
56
|
npm run data:retrieve_agenda ../senat-data -- --fromSession 2022 [--parseAgenda]
|
|
57
57
|
|
|
58
58
|
# Retrieval (& parsing) of comptes-rendus de séance from Sénat's data
|
|
59
|
-
npm run data:retrieve_cr_seance ../senat-data -- [--parseDebats]
|
|
59
|
+
npm run data:retrieve_cr_seance ../senat-data -- [--parseDebats] [--keepDir]
|
|
60
60
|
|
|
61
61
|
# Retrieval (& parsing) of comptes-rendus de commissions from Sénat's website
|
|
62
|
-
npm run data:retrieve_cr_commission ../senat-data -- [--parseDebats]
|
|
62
|
+
npm run data:retrieve_cr_commission ../senat-data -- [--parseDebats] [--keepDir]
|
|
63
63
|
|
|
64
64
|
# Retrieval of sénateurs' pictures from Sénat's website
|
|
65
65
|
npm run data:retrieve_senateurs_photos ../senat-data
|
package/lib/model/ameli.js
CHANGED
|
@@ -123,7 +123,7 @@ const findAllAmendementsQuery = dbSenat
|
|
|
123
123
|
"ameli.avigvt.lib as avis_gouvernement",
|
|
124
124
|
eb.fn.coalesce("ameli.sor.lib", "ameli.irr.libirr").as("sort"),
|
|
125
125
|
"ameli.amd.rev as revision",
|
|
126
|
-
concat(val("https://www.senat.fr/amendements/"), ref("ameli.ses.ann"), val("-"), sql `(ameli.ses.ann + 1)`, val("/"), ref("ameli.txt_ameli.numabs"), val("/Amdt_"), ref("ameli.amd.
|
|
126
|
+
concat(val("https://www.senat.fr/amendements/"), ref("ameli.ses.ann"), val("-"), sql `(ameli.ses.ann + 1)`, val("/"), ref("ameli.txt_ameli.numabs"), val("/Amdt_"), ref("ameli.amd.num"), val(".html")).as("url"),
|
|
127
127
|
"ameli.grppol_ameli.lilcou as au_nom_de_groupe_politique",
|
|
128
128
|
"ameli.com_ameli.lil as au_nom_de_commission",
|
|
129
129
|
eb.case().when("ameli.cab.entid", "is not", null).then(true).else(false).end().as("auteur_est_gouvernement"),
|
package/lib/model/dosleg.js
CHANGED
|
@@ -34,10 +34,12 @@ function rapports(lectureAssembleeId) {
|
|
|
34
34
|
.withSchema("dosleg")
|
|
35
35
|
.selectFrom("rap")
|
|
36
36
|
.leftJoin("lecassrap", "lecassrap.rapcod", "rap.rapcod")
|
|
37
|
+
.leftJoin("raporg", "raporg.rapcod", "rap.rapcod")
|
|
37
38
|
.leftJoin("denrap", "denrap.coddenrap", "rap.coddenrap")
|
|
38
39
|
.where("lecassrap.lecassidt", "=", lectureAssembleeId)
|
|
39
40
|
.select(({ eb, ref, val }) => [
|
|
40
41
|
"rap.rapnum as numero",
|
|
42
|
+
"raporg.orgcod as code_organisme",
|
|
41
43
|
eb
|
|
42
44
|
.case()
|
|
43
45
|
.when("rap.typurl", "=", "I")
|
|
@@ -84,6 +86,7 @@ function textes(lectureAssembleeId) {
|
|
|
84
86
|
.where("texte.lecassidt", "=", lectureAssembleeId)
|
|
85
87
|
.select(({ eb, ref, val }) => [
|
|
86
88
|
"texte.texnum as numero",
|
|
89
|
+
"texte.orgcod as code_organisme",
|
|
87
90
|
eb
|
|
88
91
|
.case()
|
|
89
92
|
.when("texte.typurl", "=", "I")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
1
|
+
import fs, { ensureDir } from "fs-extra";
|
|
2
2
|
import assert from "assert";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import * as cheerio from "cheerio";
|
|
@@ -187,7 +187,12 @@ async function retrieveCommissionCRs(options = {}) {
|
|
|
187
187
|
const politenessMs = Number(options["politenessMs"] ?? 150);
|
|
188
188
|
const commissionsRootDir = path.join(dataDir, COMMISSION_FOLDER);
|
|
189
189
|
const originalRoot = path.join(commissionsRootDir, DATA_ORIGINAL_FOLDER);
|
|
190
|
-
|
|
190
|
+
if (!options["keepDir"]) {
|
|
191
|
+
ensureAndClearDir(originalRoot);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
ensureDir(originalRoot);
|
|
195
|
+
}
|
|
191
196
|
const discovered = await discoverCommissionWeeklyPages(fromSession);
|
|
192
197
|
console.log(`[COM-CR][discover] ${discovered.length} links (>= session ${fromSession})`);
|
|
193
198
|
const jobs = discovered.map(({ url, yyyymmdd, commissionKey }) => {
|
|
@@ -238,7 +243,9 @@ async function retrieveCommissionCRs(options = {}) {
|
|
|
238
243
|
const sessions = getSessionsFromStart(options["fromSession"]);
|
|
239
244
|
const comRoot = path.join(dataDir, COMMISSION_FOLDER);
|
|
240
245
|
const transformedRoot = path.join(comRoot, DATA_TRANSFORMED_FOLDER);
|
|
241
|
-
if (options["
|
|
246
|
+
if (options["keepDir"])
|
|
247
|
+
ensureDir(transformedRoot);
|
|
248
|
+
else
|
|
242
249
|
ensureAndClearDir(transformedRoot);
|
|
243
250
|
for (const session of sessions) {
|
|
244
251
|
const originalSessionDir = path.join(originalRoot, String(session));
|
|
@@ -116,13 +116,19 @@ async function copyToSenat(dataset, dataDir, options) {
|
|
|
116
116
|
execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -d senat -f ${schemaDumpFile}`, {
|
|
117
117
|
env: process.env,
|
|
118
118
|
encoding: "utf-8",
|
|
119
|
-
stdio: ["ignore", "
|
|
119
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (!options["silent"]) {
|
|
124
|
+
console.error(`Failed to import ${dataset.database} schema:`);
|
|
125
|
+
if (error.stderr) {
|
|
126
|
+
console.error(error.stderr);
|
|
127
|
+
}
|
|
128
|
+
if (error.stdout) {
|
|
129
|
+
console.error(error.stdout);
|
|
130
|
+
}
|
|
124
131
|
}
|
|
125
|
-
catch { }
|
|
126
132
|
}
|
|
127
133
|
resolve();
|
|
128
134
|
});
|
|
@@ -35,6 +35,11 @@ export declare const onlyRecentOption: {
|
|
|
35
35
|
name: string;
|
|
36
36
|
type: NumberConstructor;
|
|
37
37
|
};
|
|
38
|
+
export declare const keepDirOption: {
|
|
39
|
+
help: string;
|
|
40
|
+
name: string;
|
|
41
|
+
type: BooleanConstructor;
|
|
42
|
+
};
|
|
38
43
|
export declare const commonOptions: ({
|
|
39
44
|
alias: string;
|
|
40
45
|
defaultValue: string[];
|
|
@@ -48,12 +53,11 @@ export declare const commonOptions: ({
|
|
|
48
53
|
name: string;
|
|
49
54
|
type: StringConstructor;
|
|
50
55
|
} | {
|
|
51
|
-
alias: string;
|
|
52
56
|
help: string;
|
|
53
57
|
name: string;
|
|
54
|
-
type:
|
|
58
|
+
type: NumberConstructor;
|
|
55
59
|
} | {
|
|
56
60
|
help: string;
|
|
57
61
|
name: string;
|
|
58
|
-
type:
|
|
62
|
+
type: BooleanConstructor;
|
|
59
63
|
})[];
|
|
@@ -35,6 +35,11 @@ export const onlyRecentOption = {
|
|
|
35
35
|
name: "only-recent",
|
|
36
36
|
type: Number,
|
|
37
37
|
};
|
|
38
|
+
export const keepDirOption = {
|
|
39
|
+
help: "keep directories when cleaning data",
|
|
40
|
+
name: "keepDir",
|
|
41
|
+
type: Boolean,
|
|
42
|
+
};
|
|
38
43
|
export const commonOptions = [
|
|
39
44
|
categoriesOption,
|
|
40
45
|
dataDirDefaultOption,
|
|
@@ -42,4 +47,5 @@ export const commonOptions = [
|
|
|
42
47
|
silentOption,
|
|
43
48
|
verboseOption,
|
|
44
49
|
onlyRecentOption,
|
|
50
|
+
keepDirOption,
|
|
45
51
|
];
|