@tricoteuses/senat 2.10.5 → 2.11.0
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/databases.d.ts +1 -28
- package/lib/databases.js +0 -6
- package/lib/datasets.d.ts +6 -0
- package/lib/datasets.js +233 -0
- package/lib/model/ameli.d.ts +31 -143
- package/lib/model/ameli.js +102 -95
- package/lib/model/debats.d.ts +13 -51
- package/lib/model/documents.d.ts +2 -0
- package/lib/model/documents.js +37 -0
- package/lib/model/dosleg.d.ts +9 -104
- package/lib/model/dosleg.js +76 -108
- package/lib/model/index.d.ts +4 -2
- package/lib/model/index.js +4 -2
- package/lib/model/questions.d.ts +10 -458
- package/lib/model/scrutins.d.ts +3 -0
- package/lib/model/scrutins.js +74 -0
- package/lib/model/sens.d.ts +28 -1002
- package/lib/model/sens.js +65 -33
- package/lib/raw_types/ameli.d.ts +778 -1521
- package/lib/raw_types/ameli.js +5 -345
- package/lib/raw_types/db.d.ts +11389 -0
- package/lib/raw_types/db.js +5 -0
- package/lib/raw_types/debats.d.ts +163 -306
- package/lib/raw_types/debats.js +5 -84
- package/lib/raw_types/dosleg.d.ts +1349 -2293
- package/lib/raw_types/dosleg.js +5 -550
- package/lib/raw_types/questions.d.ts +374 -519
- package/lib/raw_types/questions.js +5 -84
- package/lib/raw_types/senat.d.ts +11389 -0
- package/lib/raw_types/senat.js +5 -0
- package/lib/raw_types/sens.d.ts +6729 -12571
- package/lib/raw_types/sens.js +5 -2944
- package/lib/raw_types_schemats/ameli.d.ts +2 -2
- package/lib/raw_types_schemats/debats.d.ts +2 -2
- package/lib/raw_types_schemats/dosleg.d.ts +2 -2
- package/lib/raw_types_schemats/questions.d.ts +2 -2
- package/lib/raw_types_schemats/sens.d.ts +2 -2
- package/lib/scripts/convert_data.js +37 -31
- package/lib/scripts/retrieve_open_data.js +35 -1
- package/package.json +10 -10
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AUTO-GENERATED FILE - DO NOT EDIT!
|
|
3
3
|
*
|
|
4
|
-
* This file was automatically generated by schemats v.2.
|
|
5
|
-
* $ schemats generate -c postgres://username:password@localhost:5433/
|
|
4
|
+
* This file was automatically generated by schemats v.2.10.5
|
|
5
|
+
* $ schemats generate -c postgres://username:password@localhost:5433/senat -t amd -t amdsen -t avicom -t avigvt -t cab -t com_ameli -t ent -t etatxt -t fbu -t grppol_ameli -t gvt -t intora -t irr -t lec_ameli -t mot -t nat -t orarol -t sai -t saisen -t sea -t sen_ameli -t ses -t sor -t sub -t txt_ameli -t typrect -t typses -t typsub -t w_nivrec -s ameli
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace amdFields {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AUTO-GENERATED FILE - DO NOT EDIT!
|
|
3
3
|
*
|
|
4
|
-
* This file was automatically generated by schemats v.2.
|
|
5
|
-
* $ schemats generate -c postgres://username:password@localhost:5433/
|
|
4
|
+
* This file was automatically generated by schemats v.2.10.5
|
|
5
|
+
* $ schemats generate -c postgres://username:password@localhost:5433/senat -t debats -t intdivers -t intpjl -t lecassdeb -t secdis -t secdivers -t syndeb -t typsec -s debats
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace debatsFields {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AUTO-GENERATED FILE - DO NOT EDIT!
|
|
3
3
|
*
|
|
4
|
-
* This file was automatically generated by schemats v.2.
|
|
5
|
-
* $ schemats generate -c postgres://username:password@localhost:5433/
|
|
4
|
+
* This file was automatically generated by schemats v.2.10.5
|
|
5
|
+
* $ schemats generate -c postgres://username:password@localhost:5433/senat -t amescr -t ass -t aud -t auteur -t ble -t catrap -t corscr -t date_seance -t deccoc -t denrap -t doc -t docatt -t docsea -t ecr -t etaloi -t evtsea -t forpub -t gen -t lecass -t lecassrap -t lecture -t lnkrap -t loi -t loithe -t natloi -t org -t orgnomhis -t orippr -t oritxt -t posvot -t qua -t rap -t raporg -t rapthe -t rolsig -t scr -t ses -t stavot -t texte -t texte_ancien -t the -t titsen -t typatt -t typaut -t typdoc -t typevtsea -t typlec -t typloi -t typorg -t typrap -t typtxt -t typurl -t votsen -s dosleg
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace amescrFields {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AUTO-GENERATED FILE - DO NOT EDIT!
|
|
3
3
|
*
|
|
4
|
-
* This file was automatically generated by schemats v.2.
|
|
5
|
-
* $ schemats generate -c postgres://username:password@localhost:5433/
|
|
4
|
+
* This file was automatically generated by schemats v.2.10.5
|
|
5
|
+
* $ schemats generate -c postgres://username:password@localhost:5433/senat -t etatquestion -t legquestion -t naturequestion -t sortquestion -t tam_ministeres -t tam_questions -t tam_reponses -t the -s questions
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace etatquestionFields {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AUTO-GENERATED FILE - DO NOT EDIT!
|
|
3
3
|
*
|
|
4
|
-
* This file was automatically generated by schemats v.2.
|
|
5
|
-
* $ schemats generate -c postgres://username:password@localhost:5433/
|
|
4
|
+
* This file was automatically generated by schemats v.2.10.5
|
|
5
|
+
* $ schemats generate -c postgres://username:password@localhost:5433/senat -t acr -t activite -t activite_audit -t activite_delegation -t activite_delegation_audit -t activite_loi -t activite_loi_audit -t activite_obligatoire -t activite_participant -t activite_participant_audit -t activite_senateur -t activite_senateur_audit -t activite_senateur_params -t activite_senateur_params_audit -t activites_liees -t activites_liees_audit -t actpro -t adhgrpsen -t adr -t adresse -t adrsen -t app -t assparint -t asster -t autgrpsen -t autorisation_profil -t autorisations -t avis_nomination_art13 -t basdes -t bur -t bur3r -t bur4r -t cad -t candid -t candidat -t candtodelete -t categorie_activite -t catpro -t catpro2e -t catterrit -t cible_categorie_periode -t cirdep -t com -t con -t cotgip -t csp -t cspfam -t databasechangelog -t databasechangeloglock -t delega -t derogation -t derogation_audit -t derogation_senateur -t derogation_senateur_audit -t design -t designoep -t designorg -t discou -t div -t dpt -t dpt_seuil_presence -t dptele -t dptele_files -t dptele_processing -t dptele_processing_type -t dpttypman -t droits_acces -t droits_acces_audit -t droits_type_derogation -t ele -t eleloc -t elucan -t eludep -t eludiv -t elueur -t elueur_apf -t elumet -t elureg -t elusen -t elusen2e -t elusen3r -t elusen4r -t elusencommu -t elusenpair -t eluter -t elutit -t eluvil -t etadebman -t etadebman3r -t etadebman4r -t etafinman -t etafinman3r -t etafinman4r -t etaprr -t etarpm -t etasen -t ext2e_bio -t ext2e_csp -t ext2e_mandats -t ext2e_minist -t extsencom_identite -t extsencom_mandat -t fonact_participant -t foncandid -t foncom -t fondelega -t fongrppol -t fongrpsen -t fonmemcom -t fonmemdelega -t fonmemextpar -t fonmemgrppol -t fonmemgrpsen -t fonmemorg -t fonorg -t grppol -t grppol4r -t grpsenami -t grpsenamiadh -t grpsenamiadhreq -t grpsenamiadhreqeta -t grpsenamiunadh -t grpsim -t gvt -t insee_pays2008 -t jhi_authority -t jhi_user -t jhi_user_authority -t lanetr -t libcom -t libdelega -t libgrppol -t libgrpsen -t liborg -t lisdptele -t mel -t memcom -t memcomsea -t memdelega -t memextpar -t memgrppol -t memgrpsen -t memorg -t met -t minind -t minist -t mis -t misetafin -t mismin -t misrapeta -t missen -t moddes -t mode_acces_elusenpair -t nation -t nationgrpsen -t nivlan -t org -t orgext -t orgextpres -t orgthe -t pairie_elusenpair -t parpol -t parpolglo -t participa -t pcs -t pcs24 -t pcs42 -t pcs8 -t pcscatpro -t per -t per_sen -t perapp -t periode_presence -t perpolglo -t perrol -t pj_justificatif -t pj_justificatif_audit -t plaind -t plan_table -t plsql_profiler_runs -t plsql_profiler_units -t poicon -t posvot -t presences_scrutin_surcharge -t presencesrevisionentity -t profil_applicatif -t qua -t rap_the -t reg -t reladr -t requetes_profil -t reslis -t resultat -t reu -t revchanges -t rne_mandat -t rne_mandat_diff -t rne_sen -t rne_sen_diff -t rne_type_mandat -t rol -t sal -t scr -t scrusoldelega -t sea -t sec -t sec2e -t secexe -t sen -t senbur -t senbur3r -t senbur4r -t sennom -t senpj -t sensim -t sentablenom -t senurl -t seuil_presence -t sirpas_elusen -t sirpas_fonmemcom -t sirpas_fonmemdelega -t sirpas_fonmemgrppol -t sirpas_memcom -t sirpas_memdelega -t sirpas_memgrppol -t sirpas_mvt -t sirpas_mvtcm -t sirpas_mvttri -t sirpas_sen -t sirpas_senbur -t sirpas_trf -t srv -t stajur -t stavot -t suspensiontravaux -t suspensiontravaux_audit -t sysage -t syscognos -t sysevt -t sysvar -t sysvar_sendev -t sysvar_senprod -t tapsenrevchanges -t tapsenrevisionentity -t telephone -t temval -t tenpol -t territ -t testoracle -t titele -t titelerne -t titmin -t titnob -t tmpsd -t toutes -t turelu -t typadr -t typapppol -t typbister -t typcandid -t type_activite -t type_activite_participant -t type_activite_rol -t type_activite_senateur -t type_categorie -t type_derogation -t type_droit_acces -t type_pj_justificatif -t type_rne_diff -t type_type_derogation -t typele -t typgrpsen -t typman -t typmin -t typmoddes -t typorg -t typorgext -t typparpol -t typpoicon -t typprs -t typprssta -t typscr -t typtel -t typurl -t typvoi -t uploaded_file -t uploaded_file_type -t validation -t validation_defview_profil -t validation_profil -t vercand -t verres -t votes -t zongeo -s sens
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace acrFields {
|
|
@@ -21,14 +21,14 @@ async function convertData() {
|
|
|
21
21
|
const enabledDatasets = getEnabledDatasets(options["categories"]);
|
|
22
22
|
console.time("data transformation time");
|
|
23
23
|
if (enabledDatasets & EnabledDatasets.Ameli) {
|
|
24
|
-
await convertDatasetAmeli(dataDir);
|
|
24
|
+
await convertDatasetAmeli(dataDir, options);
|
|
25
25
|
}
|
|
26
26
|
if (enabledDatasets & EnabledDatasets.Debats) {
|
|
27
|
-
await convertDatasetDebats(dataDir);
|
|
27
|
+
await convertDatasetDebats(dataDir, options);
|
|
28
28
|
}
|
|
29
29
|
if (enabledDatasets & EnabledDatasets.DosLeg) {
|
|
30
|
-
await convertDatasetDosLeg(dataDir);
|
|
31
|
-
await convertDatasetScrutins(dataDir);
|
|
30
|
+
await convertDatasetDosLeg(dataDir, options);
|
|
31
|
+
await convertDatasetScrutins(dataDir, options);
|
|
32
32
|
}
|
|
33
33
|
if (enabledDatasets & EnabledDatasets.Questions) {
|
|
34
34
|
await convertDatasetQuestions(dataDir);
|
|
@@ -40,27 +40,27 @@ async function convertData() {
|
|
|
40
40
|
console.timeEnd("data transformation time");
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
async function convertDatasetAmeli(dataDir) {
|
|
43
|
+
async function convertDatasetAmeli(dataDir, options) {
|
|
44
44
|
const dataset = datasets.ameli;
|
|
45
45
|
if (!options["silent"]) {
|
|
46
46
|
console.log(`Converting database ${dataset.database} data into files…`);
|
|
47
47
|
}
|
|
48
48
|
const ameliReorganizedRootDir = path.join(dataDir, dataset.database);
|
|
49
49
|
ensureAndClearDir(ameliReorganizedRootDir);
|
|
50
|
-
for await (const amendement of findAllAmendements()) {
|
|
50
|
+
for await (const amendement of findAllAmendements(options["fromSession"])) {
|
|
51
51
|
if (options["verbose"]) {
|
|
52
|
-
console.log(`Converting ${amendement
|
|
52
|
+
console.log(`Converting ${amendement["numero"]} file…`);
|
|
53
53
|
}
|
|
54
|
-
const session = String(amendement
|
|
55
|
-
const signetDossierLegislatif = amendement
|
|
56
|
-
`${amendement
|
|
54
|
+
const session = String(amendement["session"]) || UNDEFINED_SESSION;
|
|
55
|
+
const signetDossierLegislatif = amendement["signet_dossier_legislatif"] ||
|
|
56
|
+
`${amendement["nature_texte"]}-${amendement["numero_texte"]}`.toLowerCase();
|
|
57
57
|
const ameliReorganizedDir = path.join(ameliReorganizedRootDir, String(session), signetDossierLegislatif);
|
|
58
58
|
fs.ensureDirSync(ameliReorganizedDir);
|
|
59
|
-
const amendementFileName = `${amendement
|
|
59
|
+
const amendementFileName = `${amendement["numero"]}.json`;
|
|
60
60
|
fs.writeJSONSync(path.join(ameliReorganizedDir, amendementFileName), amendement, { spaces: 2 });
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
async function convertDatasetDebats(dataDir) {
|
|
63
|
+
async function convertDatasetDebats(dataDir, options) {
|
|
64
64
|
const dataset = datasets.debats;
|
|
65
65
|
if (!options["silent"]) {
|
|
66
66
|
console.log(`Converting database ${dataset.database} data into files…`);
|
|
@@ -74,6 +74,9 @@ async function convertDatasetDebats(dataDir) {
|
|
|
74
74
|
}
|
|
75
75
|
const enrichedDebat = await enrichDebat(debat, allAuteurs);
|
|
76
76
|
const session = getSessionFromDate(enrichedDebat.date_seance);
|
|
77
|
+
if (options["fromSession"] && session < options["fromSession"]) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
77
80
|
const debatsReorganizedDir = path.join(debatsReorganizedRootDir, String(session));
|
|
78
81
|
fs.ensureDirSync(debatsReorganizedDir);
|
|
79
82
|
const debatFileName = `${enrichedDebat.id}.json`;
|
|
@@ -84,12 +87,12 @@ async function enrichDebat(debat, auteurs) {
|
|
|
84
87
|
const enrichedDebat = { ...debat };
|
|
85
88
|
for (const section of enrichedDebat.sections) {
|
|
86
89
|
for (const intervention of section.interventions) {
|
|
87
|
-
intervention.auteur = findAuteur(intervention
|
|
90
|
+
intervention.auteur = findAuteur(intervention["auteur_code"], auteurs);
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
for (const section of enrichedDebat.sections_divers) {
|
|
91
94
|
for (const intervention of section.interventions) {
|
|
92
|
-
intervention.auteur = findAuteur(intervention
|
|
95
|
+
intervention.auteur = findAuteur(intervention["auteur_code"], auteurs);
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
return enrichedDebat;
|
|
@@ -97,7 +100,7 @@ async function enrichDebat(debat, auteurs) {
|
|
|
97
100
|
function findAuteur(auteurCode, auteurs) {
|
|
98
101
|
return auteurs.find(auteur => auteur.code === auteurCode);
|
|
99
102
|
}
|
|
100
|
-
async function convertDatasetDosLeg(dataDir) {
|
|
103
|
+
async function convertDatasetDosLeg(dataDir, options) {
|
|
101
104
|
const dataset = datasets.dosleg;
|
|
102
105
|
if (!options["silent"]) {
|
|
103
106
|
console.log(`Converting database ${dataset.database} data into files…`);
|
|
@@ -112,6 +115,9 @@ async function convertDatasetDosLeg(dataDir) {
|
|
|
112
115
|
}
|
|
113
116
|
let loiReorganizedDir = path.join(dossiersReorganizedDir, String(UNDEFINED_SESSION));
|
|
114
117
|
const session = getSessionFromSignet(loi["signet"]) || UNDEFINED_SESSION;
|
|
118
|
+
if (options["fromSession"] && session < options["fromSession"]) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
115
121
|
loiReorganizedDir = path.join(dossiersReorganizedDir, String(session));
|
|
116
122
|
fs.ensureDirSync(loiReorganizedDir);
|
|
117
123
|
const scrutinFileName = `${loi["signet"]}.json`;
|
|
@@ -122,22 +128,22 @@ async function convertDatasetDosLeg(dataDir) {
|
|
|
122
128
|
await convertTexteUrls(dataDir);
|
|
123
129
|
await convertRapportUrls(dataDir);
|
|
124
130
|
}
|
|
125
|
-
async function convertDatasetScrutins(dataDir) {
|
|
131
|
+
async function convertDatasetScrutins(dataDir, options) {
|
|
126
132
|
const dataset = datasets.dosleg;
|
|
127
133
|
if (!options["silent"]) {
|
|
128
|
-
console.log(`Converting database ${dataset.database}
|
|
134
|
+
console.log(`Converting database scrutins (${dataset.database}) data into files…`);
|
|
129
135
|
}
|
|
130
136
|
const scrutinsReorganizedDir = path.join(dataDir, SCRUTINS_FOLDER);
|
|
131
137
|
ensureAndClearDir(scrutinsReorganizedDir);
|
|
132
|
-
for await (const scrutin of findAllScrutins()) {
|
|
138
|
+
for await (const scrutin of findAllScrutins(options["fromSession"])) {
|
|
133
139
|
if (options["verbose"]) {
|
|
134
|
-
console.log(`Converting ${scrutin
|
|
140
|
+
console.log(`Converting ${scrutin["numero"]} file…`);
|
|
135
141
|
}
|
|
136
142
|
let scrutinReorganizedDir = path.join(scrutinsReorganizedDir, String(UNDEFINED_SESSION));
|
|
137
|
-
const session = scrutin
|
|
143
|
+
const session = scrutin["session"] || UNDEFINED_SESSION;
|
|
138
144
|
scrutinReorganizedDir = path.join(scrutinsReorganizedDir, String(session));
|
|
139
145
|
fs.ensureDirSync(scrutinReorganizedDir);
|
|
140
|
-
const scrutinFileName = `${scrutin
|
|
146
|
+
const scrutinFileName = `${scrutin["numero"]}.json`;
|
|
141
147
|
fs.writeJSONSync(path.join(scrutinReorganizedDir, scrutinFileName), scrutin, {
|
|
142
148
|
spaces: 2,
|
|
143
149
|
});
|
|
@@ -152,12 +158,12 @@ async function convertDatasetQuestions(dataDir) {
|
|
|
152
158
|
ensureAndClearDir(questionsReorganizedRootDir);
|
|
153
159
|
for await (const question of findAllQuestions()) {
|
|
154
160
|
if (options["verbose"]) {
|
|
155
|
-
console.log(`Converting ${question
|
|
161
|
+
console.log(`Converting ${question["reference"]} file…`);
|
|
156
162
|
}
|
|
157
|
-
const legislature = question
|
|
163
|
+
const legislature = question["legislature"] ? question["legislature"] : 0;
|
|
158
164
|
const questionReorganizedDir = path.join(questionsReorganizedRootDir, String(legislature));
|
|
159
165
|
fs.ensureDirSync(questionReorganizedDir);
|
|
160
|
-
const questionFileName = `${question
|
|
166
|
+
const questionFileName = `${question["reference"]}.json`;
|
|
161
167
|
fs.writeJSONSync(path.join(questionReorganizedDir, questionFileName), question, { spaces: 2 });
|
|
162
168
|
}
|
|
163
169
|
}
|
|
@@ -229,26 +235,26 @@ async function convertDatasetSens(dataDir) {
|
|
|
229
235
|
ensureAndClearDir(organismesReorganizedDir);
|
|
230
236
|
for await (const sen of findAllSens()) {
|
|
231
237
|
if (options["verbose"]) {
|
|
232
|
-
console.log(`Converting ${sen
|
|
238
|
+
console.log(`Converting ${sen["matricule"]} file…`);
|
|
233
239
|
}
|
|
234
|
-
const senFileName = `${sen
|
|
240
|
+
const senFileName = `${sen["matricule"]}.json`;
|
|
235
241
|
fs.writeJSONSync(path.join(senateursReorganizedDir, senFileName), sen, {
|
|
236
242
|
spaces: 2,
|
|
237
243
|
});
|
|
238
244
|
}
|
|
239
245
|
for await (const circonscription of findAllCirconscriptions()) {
|
|
240
246
|
if (options["verbose"]) {
|
|
241
|
-
console.log(`Converting ${circonscription
|
|
247
|
+
console.log(`Converting ${circonscription["identifiant"]} file…`);
|
|
242
248
|
}
|
|
243
|
-
const circonscriptionFileName = `${circonscription
|
|
249
|
+
const circonscriptionFileName = `${circonscription["identifiant"]}.json`;
|
|
244
250
|
fs.writeJSONSync(path.join(circonscriptionsReorganizedDir, circonscriptionFileName), circonscription, { spaces: 2 });
|
|
245
251
|
}
|
|
246
252
|
for await (const organisme of findAllOrganismes()) {
|
|
247
253
|
if (options["verbose"]) {
|
|
248
|
-
console.log(`Converting ${organisme
|
|
254
|
+
console.log(`Converting ${organisme["code"]} file…`);
|
|
249
255
|
}
|
|
250
|
-
const organismeFileName = `${organisme
|
|
251
|
-
const organismeDir = path.join(organismesReorganizedDir, organisme
|
|
256
|
+
const organismeFileName = `${organisme["code"]}.json`;
|
|
257
|
+
const organismeDir = path.join(organismesReorganizedDir, organisme["type_code"]);
|
|
252
258
|
fs.ensureDirSync(organismeDir);
|
|
253
259
|
fs.writeJSONSync(path.join(organismeDir, organismeFileName), organisme, { spaces: 2 });
|
|
254
260
|
}
|
|
@@ -202,6 +202,30 @@ async function retrieveDataset(dataDir, dataset) {
|
|
|
202
202
|
console.log(`Importing ${dataset.title}: ${sqlFilename}…`);
|
|
203
203
|
}
|
|
204
204
|
await copyToSenat(dataset, dataDir, options);
|
|
205
|
+
// Create indexes programmatically after import
|
|
206
|
+
if (dataset.indexes) {
|
|
207
|
+
for (const [table, indexes] of Object.entries(dataset.indexes)) {
|
|
208
|
+
for (const index of indexes) {
|
|
209
|
+
const indexName = index.name;
|
|
210
|
+
const columns = index.columns.join(", ");
|
|
211
|
+
const schema = dataset.database;
|
|
212
|
+
const sql = `CREATE INDEX IF NOT EXISTS ${indexName} ON ${schema}.${table} (${columns});`;
|
|
213
|
+
try {
|
|
214
|
+
execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -d senat -c "${sql}"`, {
|
|
215
|
+
env: process.env,
|
|
216
|
+
encoding: "utf-8",
|
|
217
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
218
|
+
});
|
|
219
|
+
if (!options["silent"]) {
|
|
220
|
+
console.log(`Created index: ${indexName} on ${schema}.${table} (${columns})`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
console.error(`Failed to create index ${indexName} on ${schema}.${table}:`, err);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
205
229
|
}
|
|
206
230
|
if (options["schema"]) {
|
|
207
231
|
let definitionsDir = path.resolve("src", "raw_types_schemats");
|
|
@@ -224,7 +248,7 @@ async function retrieveDataset(dataDir, dataset) {
|
|
|
224
248
|
fs.writeFileSync(definitionFilePath, definitionRepaired);
|
|
225
249
|
definitionsDir = path.resolve("src", "raw_types");
|
|
226
250
|
definitionFilePath = path.join(definitionsDir, `${dataset.database}.ts`);
|
|
227
|
-
execSync(`npx
|
|
251
|
+
execSync(`npx kysely-codegen --url '${dbConnectionString}' --default-schema ${dataset.database} --include-pattern '${dataset.database}.*' --out-file ${definitionFilePath}`, {
|
|
228
252
|
env: process.env,
|
|
229
253
|
encoding: "utf-8",
|
|
230
254
|
// stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -261,6 +285,16 @@ async function retrieveOpenData() {
|
|
|
261
285
|
for (const dataset of chosenDatasets) {
|
|
262
286
|
await retrieveDataset(dataDir, dataset);
|
|
263
287
|
}
|
|
288
|
+
if (options["schema"]) {
|
|
289
|
+
const dbConnectionString = `postgres://${process.env["PGUSER"]}:${process.env["PGPASSWORD"]}@${process.env["PGHOST"]}:${process.env["PGPORT"]}/senat`;
|
|
290
|
+
const definitionsDir = path.resolve("src", "raw_types");
|
|
291
|
+
const definitionFilePath = path.join(definitionsDir, `senat.ts`);
|
|
292
|
+
execSync(`npx kysely-codegen --url '${dbConnectionString}' --out-file ${definitionFilePath}`, {
|
|
293
|
+
env: process.env,
|
|
294
|
+
encoding: "utf-8",
|
|
295
|
+
// stdio: ["ignore", "ignore", "pipe"],
|
|
296
|
+
});
|
|
297
|
+
}
|
|
264
298
|
if (!options["silent"]) {
|
|
265
299
|
console.timeEnd("data extraction time");
|
|
266
300
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tricoteuses/senat",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Handle French Sénat's open data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"France",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"fs-extra": "^9.1.0",
|
|
67
67
|
"jsdom": "^26.0.0",
|
|
68
68
|
"kysely": "^0.27.4",
|
|
69
|
-
"luxon": "^3.
|
|
69
|
+
"luxon": "^3.7.2",
|
|
70
70
|
"node-stream-zip": "^1.8.2",
|
|
71
71
|
"pg": "^8.13.1",
|
|
72
72
|
"pg-cursor": "^2.12.1",
|
|
73
73
|
"slug": "^11.0.0",
|
|
74
|
-
"tsx": "^4.
|
|
74
|
+
"tsx": "^4.20.6",
|
|
75
75
|
"windows-1252": "^1.0.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
@@ -80,19 +80,19 @@
|
|
|
80
80
|
"@types/command-line-args": "^5.0.0",
|
|
81
81
|
"@types/fs-extra": "^9.0.7",
|
|
82
82
|
"@types/jsdom": "^21.1.7",
|
|
83
|
-
"@types/luxon": "^3.
|
|
83
|
+
"@types/luxon": "^3.7.1",
|
|
84
84
|
"@types/node": "^20.17.6",
|
|
85
|
-
"@types/pg": "^8.
|
|
85
|
+
"@types/pg": "^8.15.5",
|
|
86
86
|
"@types/pg-cursor": "^2.7.2",
|
|
87
87
|
"@types/slug": "^5.0.9",
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
89
|
-
"@typescript-eslint/parser": "^8.
|
|
90
|
-
"cross-env": "^10.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
|
89
|
+
"@typescript-eslint/parser": "^8.46.0",
|
|
90
|
+
"cross-env": "^10.1.0",
|
|
91
91
|
"eslint": "^8.57.1",
|
|
92
92
|
"iconv-lite": "^0.7.0",
|
|
93
|
-
"
|
|
93
|
+
"kysely-codegen": "^0.19.0",
|
|
94
94
|
"prettier": "^3.5.3",
|
|
95
95
|
"tslib": "^2.1.0",
|
|
96
|
-
"typescript": "^5.
|
|
96
|
+
"typescript": "^5.9.3"
|
|
97
97
|
}
|
|
98
98
|
}
|