@tricoteuses/senat 2.22.0 → 2.22.2

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.
Files changed (129) hide show
  1. package/package.json +2 -2
  2. package/lib/config.d.ts +0 -3
  3. package/lib/config.js +0 -16
  4. package/lib/databases.d.ts +0 -2
  5. package/lib/databases.js +0 -26
  6. package/lib/datasets.d.ts +0 -34
  7. package/lib/datasets.js +0 -233
  8. package/lib/git.d.ts +0 -26
  9. package/lib/git.js +0 -167
  10. package/lib/index.d.ts +0 -13
  11. package/lib/index.js +0 -1
  12. package/lib/loaders.d.ts +0 -58
  13. package/lib/loaders.js +0 -286
  14. package/lib/model/agenda.d.ts +0 -6
  15. package/lib/model/agenda.js +0 -148
  16. package/lib/model/ameli.d.ts +0 -51
  17. package/lib/model/ameli.js +0 -149
  18. package/lib/model/commission.d.ts +0 -18
  19. package/lib/model/commission.js +0 -269
  20. package/lib/model/debats.d.ts +0 -67
  21. package/lib/model/debats.js +0 -95
  22. package/lib/model/documents.d.ts +0 -12
  23. package/lib/model/documents.js +0 -151
  24. package/lib/model/dosleg.d.ts +0 -7
  25. package/lib/model/dosleg.js +0 -326
  26. package/lib/model/index.d.ts +0 -7
  27. package/lib/model/index.js +0 -7
  28. package/lib/model/questions.d.ts +0 -45
  29. package/lib/model/questions.js +0 -89
  30. package/lib/model/scrutins.d.ts +0 -13
  31. package/lib/model/scrutins.js +0 -114
  32. package/lib/model/seance.d.ts +0 -3
  33. package/lib/model/seance.js +0 -267
  34. package/lib/model/sens.d.ts +0 -146
  35. package/lib/model/sens.js +0 -454
  36. package/lib/model/texte.d.ts +0 -7
  37. package/lib/model/texte.js +0 -228
  38. package/lib/model/util.d.ts +0 -9
  39. package/lib/model/util.js +0 -38
  40. package/lib/parsers/texte.d.ts +0 -7
  41. package/lib/parsers/texte.js +0 -228
  42. package/lib/raw_types/ameli.d.ts +0 -914
  43. package/lib/raw_types/ameli.js +0 -5
  44. package/lib/raw_types/debats.d.ts +0 -207
  45. package/lib/raw_types/debats.js +0 -5
  46. package/lib/raw_types/dosleg.d.ts +0 -1619
  47. package/lib/raw_types/dosleg.js +0 -5
  48. package/lib/raw_types/questions.d.ts +0 -419
  49. package/lib/raw_types/questions.js +0 -5
  50. package/lib/raw_types/senat.d.ts +0 -11368
  51. package/lib/raw_types/senat.js +0 -5
  52. package/lib/raw_types/sens.d.ts +0 -8248
  53. package/lib/raw_types/sens.js +0 -5
  54. package/lib/raw_types_schemats/ameli.d.ts +0 -539
  55. package/lib/raw_types_schemats/ameli.js +0 -2
  56. package/lib/raw_types_schemats/debats.d.ts +0 -127
  57. package/lib/raw_types_schemats/debats.js +0 -2
  58. package/lib/raw_types_schemats/dosleg.d.ts +0 -977
  59. package/lib/raw_types_schemats/dosleg.js +0 -2
  60. package/lib/raw_types_schemats/questions.d.ts +0 -235
  61. package/lib/raw_types_schemats/questions.js +0 -2
  62. package/lib/raw_types_schemats/sens.d.ts +0 -6915
  63. package/lib/raw_types_schemats/sens.js +0 -2
  64. package/lib/scripts/convert_data.d.ts +0 -1
  65. package/lib/scripts/convert_data.js +0 -354
  66. package/lib/scripts/data-download.d.ts +0 -1
  67. package/lib/scripts/data-download.js +0 -12
  68. package/lib/scripts/datautil.d.ts +0 -8
  69. package/lib/scripts/datautil.js +0 -34
  70. package/lib/scripts/parse_textes.d.ts +0 -1
  71. package/lib/scripts/parse_textes.js +0 -44
  72. package/lib/scripts/retrieve_agenda.d.ts +0 -1
  73. package/lib/scripts/retrieve_agenda.js +0 -132
  74. package/lib/scripts/retrieve_cr_commission.d.ts +0 -1
  75. package/lib/scripts/retrieve_cr_commission.js +0 -364
  76. package/lib/scripts/retrieve_cr_seance.d.ts +0 -6
  77. package/lib/scripts/retrieve_cr_seance.js +0 -347
  78. package/lib/scripts/retrieve_documents.d.ts +0 -3
  79. package/lib/scripts/retrieve_documents.js +0 -219
  80. package/lib/scripts/retrieve_open_data.d.ts +0 -1
  81. package/lib/scripts/retrieve_open_data.js +0 -315
  82. package/lib/scripts/retrieve_senateurs_photos.d.ts +0 -1
  83. package/lib/scripts/retrieve_senateurs_photos.js +0 -147
  84. package/lib/scripts/retrieve_videos.d.ts +0 -1
  85. package/lib/scripts/retrieve_videos.js +0 -461
  86. package/lib/scripts/shared/cli_helpers.d.ts +0 -95
  87. package/lib/scripts/shared/cli_helpers.js +0 -91
  88. package/lib/scripts/shared/util.d.ts +0 -4
  89. package/lib/scripts/shared/util.js +0 -35
  90. package/lib/scripts/test_iter_load.d.ts +0 -1
  91. package/lib/scripts/test_iter_load.js +0 -12
  92. package/lib/strings.d.ts +0 -1
  93. package/lib/strings.js +0 -18
  94. package/lib/types/agenda.d.ts +0 -44
  95. package/lib/types/agenda.js +0 -1
  96. package/lib/types/ameli.d.ts +0 -5
  97. package/lib/types/ameli.js +0 -1
  98. package/lib/types/compte_rendu.d.ts +0 -83
  99. package/lib/types/compte_rendu.js +0 -1
  100. package/lib/types/debats.d.ts +0 -2
  101. package/lib/types/debats.js +0 -1
  102. package/lib/types/dosleg.d.ts +0 -70
  103. package/lib/types/dosleg.js +0 -1
  104. package/lib/types/questions.d.ts +0 -2
  105. package/lib/types/questions.js +0 -1
  106. package/lib/types/sens.d.ts +0 -10
  107. package/lib/types/sens.js +0 -1
  108. package/lib/types/sessions.d.ts +0 -5
  109. package/lib/types/sessions.js +0 -84
  110. package/lib/types/texte.d.ts +0 -74
  111. package/lib/types/texte.js +0 -16
  112. package/lib/utils/cr_spliting.d.ts +0 -28
  113. package/lib/utils/cr_spliting.js +0 -265
  114. package/lib/utils/date.d.ts +0 -10
  115. package/lib/utils/date.js +0 -100
  116. package/lib/utils/nvs-timecode.d.ts +0 -7
  117. package/lib/utils/nvs-timecode.js +0 -79
  118. package/lib/utils/reunion_grouping.d.ts +0 -11
  119. package/lib/utils/reunion_grouping.js +0 -337
  120. package/lib/utils/reunion_odj_building.d.ts +0 -5
  121. package/lib/utils/reunion_odj_building.js +0 -154
  122. package/lib/utils/reunion_parsing.d.ts +0 -23
  123. package/lib/utils/reunion_parsing.js +0 -209
  124. package/lib/utils/scoring.d.ts +0 -14
  125. package/lib/utils/scoring.js +0 -147
  126. package/lib/utils/string_cleaning.d.ts +0 -7
  127. package/lib/utils/string_cleaning.js +0 -57
  128. package/lib/validators/config.d.ts +0 -1
  129. package/lib/validators/config.js +0 -54
@@ -1,326 +0,0 @@
1
- import { sql } from "kysely";
2
- import { jsonArrayFrom } from "kysely/helpers/postgres";
3
- import { dbSenat } from "../databases";
4
- import { concat, rtrim, toDateString } from "./util";
5
- import { textes, rapports } from "./documents";
6
- function datesSeances(lectureAssembleeId) {
7
- return jsonArrayFrom(dbSenat
8
- .withSchema("dosleg")
9
- .selectFrom("dosleg.date_seance")
10
- .where("dosleg.date_seance.lecidt", "=", lectureAssembleeId)
11
- .select(({ ref }) => [toDateString(ref("dosleg.date_seance.date_s")).as("date")]));
12
- }
13
- function lecturesAssemblee(lectureId) {
14
- return jsonArrayFrom(dbSenat
15
- .withSchema("dosleg")
16
- .selectFrom("lecass")
17
- .where("lecass.lecidt", "=", lectureId)
18
- .leftJoin("ass", "ass.codass", "lecass.codass")
19
- .leftJoin("org", "org.orgcod", "lecass.orgcod")
20
- .leftJoin("orippr", "orippr.oripprcod", "lecass.orippr")
21
- .select(({ ref }) => [
22
- rtrim(ref("ass.libass")).as("assemblee"),
23
- "org.orgnom as libelle_organisme",
24
- "org.senorgcod as code_organisme",
25
- "lecass.ordreass as ordre_lecture_assemblee",
26
- "lecass.sesann as session",
27
- "orippr.oripprlib as origine_proposition",
28
- "lecass.ptlnum as numero_petite_loi",
29
- "lecass.ptlurl as url_petite_loi",
30
- "lecass.loiintmod as loi_intitule_modifie",
31
- "lecass.debatsurl as url_cr_debats",
32
- toDateString(ref("lecass.lecassamecomdat")).as("date_publication_amendements_commission"),
33
- toDateString(ref("lecass.lecassamedat")).as("date_publication_amendements_seance"),
34
- textes(ref("lecass.lecassidt")).as("textes"),
35
- rapports(ref("lecass.lecassidt")).as("rapports"),
36
- datesSeances(ref("lecass.lecassidt")).as("dates_seances"),
37
- ])
38
- .orderBy("lecass.ordreass", "asc"));
39
- }
40
- function lectures(loiId) {
41
- return jsonArrayFrom(dbSenat
42
- .withSchema("dosleg")
43
- .selectFrom("lecture")
44
- .leftJoin("typlec", "typlec.typleccod", "lecture.typleccod")
45
- .where("lecture.loicod", "=", loiId)
46
- .select(({ ref }) => [
47
- rtrim(ref("typlec.typleclib")).as("type_lecture"),
48
- rtrim(ref("lecture.leccom")).as("libelle"),
49
- "typlec.typlecord as ordre_lecture",
50
- lecturesAssemblee(ref("lecture.lecidt")).as("lectures_assemblee"),
51
- ])
52
- .orderBy("typlec.typlecord", "asc"));
53
- }
54
- function themes(loiId) {
55
- return jsonArrayFrom(dbSenat
56
- .withSchema("dosleg")
57
- .selectFrom("the")
58
- .leftJoin("loithe", "loithe.thecle", "the.thecle")
59
- .where("loithe.loicod", "=", loiId)
60
- .select(["the.thelib as libelle"]));
61
- }
62
- const findAllDossiersQuery = dbSenat
63
- .withSchema("dosleg")
64
- .selectFrom("loi")
65
- .leftJoin("typloi", "typloi.typloicod", "loi.typloicod")
66
- .leftJoin("etaloi", "etaloi.etaloicod", "loi.etaloicod")
67
- .leftJoin("deccoc", "deccoc.deccoccod", "loi.deccoccod")
68
- .select(({ eb, ref, val }) => [
69
- rtrim(ref("loi.loicod")).as("code"),
70
- "loi.numero as numero",
71
- "loi.signet as signet",
72
- sql `NULLIF(regexp_replace(loi.url_an, '^.*\\/(DL[^\\/]+)\\.asp$', '\\1'), '')`.as("code_dossier_an"),
73
- "loi.signetalt as signet_alternatif",
74
- rtrim(ref("loi.motclef")).as("mot_cle"),
75
- rtrim(ref("loi.loient")).as("titre_court"),
76
- concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loitit"))).as("titre"),
77
- concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loiint"))).as("titre_long"),
78
- concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loiintori"))).as("titre_long_original"),
79
- concat(val("https://www.senat.fr/dossier-legislatif/"), ref("loi.signet"), val(".html")).as("url"),
80
- "loi.urgence as urgence",
81
- rtrim(ref("typloi.groupe")).as("code_nature_dossier"),
82
- rtrim(ref("typloi.typloilib")).as("libelle_type_dossier"),
83
- rtrim(ref("etaloi.etaloilib")).as("etat_dossier"),
84
- "loi.url_an as url_dossier_assemblee_nationale",
85
- "loi.url_presart as url_presentation_articles",
86
- "loi.url_ordonnance as url_ordonnance",
87
- "loi.orgcod as code_organisme_resolution",
88
- "deccoc.deccoclib as libelle_decision_CoC",
89
- toDateString(ref("loi.date_decision")).as("date_decision_CoC"),
90
- "loi.num_decision as num_decision_CoC",
91
- "loi.deccocurl as url_decision_CoC",
92
- "loi.doscocurl as url_dossier_CoC",
93
- toDateString(ref("loi.saisine_date")).as("date_saisine_CoC"),
94
- "loi.saisine_par as condition_saisine_CoC",
95
- toDateString(ref("loi.proaccdat")).as("date_procedure_acceleree"),
96
- toDateString(ref("loi.proaccoppdat")).as("date_opposition_procedure_acceleree"),
97
- toDateString(ref("loi.retproaccdat")).as("date_retrait_procedure_acceleree"),
98
- toDateString(ref("loi.date_loi")).as("date_promulgation"),
99
- eb
100
- .case()
101
- .when("loi.loititjo", "is not", null)
102
- .then(concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loititjo"))))
103
- .else("")
104
- .end()
105
- .as("titre_JO"),
106
- toDateString(ref("loi.loidatjo")).as("date_publication_JO"),
107
- "loi.loinumjo as numero_JO",
108
- "loi.url_jo as url_JO",
109
- toDateString(ref("loi.loidatjo2")).as("date_publication_JO_correctif_1"),
110
- "loi.loinumjo2 as numero_JO_correctif_1",
111
- "loi.url_jo2 as url_JO_correctif_1",
112
- toDateString(ref("loi.loidatjo3")).as("date_publication_JO_correctif_2"),
113
- "loi.loinumjo3 as numero_JO_correctif_2",
114
- "loi.url_jo3 as url_JO_correctif_2",
115
- lectures(ref("loi.loicod")).as("lectures"),
116
- themes(ref("loi.loicod")).as("themes"),
117
- ])
118
- .$narrowType();
119
- export function findAllDossiers() {
120
- return findAllDossiersQuery.stream();
121
- }
122
- export function getCodeActeLecture(codeNatureDossier, typeLecture, assemblee) {
123
- const codeAssemblee = assemblee === "Sénat" ? "SN" : assemblee === "Assemblée nationale" ? "AN" : null;
124
- if (typeLecture === "Commission mixte paritaire") {
125
- return "CMP";
126
- }
127
- if (!codeAssemblee) {
128
- return null;
129
- }
130
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Première lecture") {
131
- return `${codeAssemblee}1`;
132
- }
133
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Deuxième lecture") {
134
- return `${codeAssemblee}2`;
135
- }
136
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Troisième lecture") {
137
- return `${codeAssemblee}3`;
138
- }
139
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Quatrième lecture") {
140
- return `${codeAssemblee}4`;
141
- }
142
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Nouvelle lecture") {
143
- return `${codeAssemblee}NLEC`;
144
- }
145
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Lecture définitive") {
146
- return `${codeAssemblee}LDEF`;
147
- }
148
- if (["ppr"].includes(codeNatureDossier) && typeLecture === "Première lecture") {
149
- return `${codeAssemblee}LUNI`;
150
- }
151
- return null;
152
- }
153
- // Helper pour déterminer le code de phase (SN1, SN2, CMP...)
154
- function getPhasePrefix(lecture, assemblee) {
155
- if (assemblee !== "Sénat")
156
- return null;
157
- const typeLibelle = (lecture.type_lecture || "").toLowerCase();
158
- if (typeLibelle.includes("cmp") || typeLibelle.includes("mixte"))
159
- return "CMP";
160
- if (typeLibelle.includes("nouvelle lecture"))
161
- return "SNNLEC";
162
- if (typeLibelle.includes("d\u00e9finitive"))
163
- return "SNLDEF";
164
- if (typeLibelle.includes("unique"))
165
- return "SNLUNI";
166
- if (lecture.ordre_lecture) {
167
- return `SN${lecture.ordre_lecture}`;
168
- }
169
- if (typeLibelle.includes("premi\u00e8re"))
170
- return "SN1";
171
- if (typeLibelle.includes("deuxi\u00e8me") || typeLibelle.includes("seconde"))
172
- return "SN2";
173
- return "SN1";
174
- }
175
- export function buildActesLegislatifs(dossier) {
176
- const actes = [];
177
- const loiSignet = dossier.signet;
178
- const lectures = dossier.lectures || [];
179
- for (const lecture of lectures) {
180
- const lecturesAssemblee = lecture.lectures_assemblee || [];
181
- for (const lecAss of lecturesAssemblee) {
182
- // On ne traite que la partie SÉNAT
183
- if (lecAss.assemblee !== "Sénat")
184
- continue;
185
- const phasePrefix = getPhasePrefix(lecture, lecAss.assemblee);
186
- if (!phasePrefix)
187
- continue;
188
- // Préparation des textes (tri chronologique)
189
- const textes = lecAss.textes || [];
190
- const textesTries = [...textes].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
191
- // =================================================================
192
- // A. DÉPÔT
193
- // =================================================================
194
- const depotTexte = textesTries.find((t) => (t.origine || "").toLowerCase().includes("déposé") ||
195
- (t.origine || "").toLowerCase().includes("transmis") ||
196
- t.ordre_origine === "0");
197
- if (depotTexte && depotTexte.date) {
198
- actes.push({
199
- code_acte: `${phasePrefix}-DEPOT`,
200
- date: depotTexte.date,
201
- libelle: `Dépôt du texte n°${depotTexte.numero}`,
202
- id: depotTexte.id,
203
- numero: depotTexte.numero,
204
- uid: `${loiSignet}-${phasePrefix}-DEPOT`,
205
- session: lecAss.session,
206
- chambre: 'SN',
207
- signet_dossier: loiSignet,
208
- texte_url: depotTexte.url,
209
- code_organisme: null
210
- });
211
- }
212
- // =================================================================
213
- // B. COMMISSION (Rapports)
214
- // =================================================================
215
- const rapports = lecAss.rapports || [];
216
- for (const rap of rapports) {
217
- if (rap.date) {
218
- actes.push({
219
- code_acte: `${phasePrefix}-COM-FOND`,
220
- date: rap.date,
221
- libelle: `Rapport n°${rap.numero} de la commission`,
222
- id: rap.id,
223
- numero: rap.numero,
224
- code_organisme: rap.code_organisme,
225
- adoption: rap.adoption,
226
- uid: `${loiSignet}-${phasePrefix}-COM`,
227
- session: lecAss.session,
228
- chambre: 'SN',
229
- signet_dossier: loiSignet,
230
- texte_url: rap.url,
231
- });
232
- }
233
- }
234
- // =================================================================
235
- // C. SÉANCE PUBLIQUE
236
- // =================================================================
237
- const datesSeances = lecAss.dates_seances || [];
238
- if (datesSeances.length > 0) {
239
- // Tri des objets dates
240
- datesSeances.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
241
- const premiereSeance = datesSeances[0];
242
- if (premiereSeance && premiereSeance.date) {
243
- actes.push({
244
- // Champs pour buildParlementActeLegislatif
245
- code_acte: `${phasePrefix}-DEBATS-SEANCE`,
246
- date: premiereSeance.date,
247
- libelle: `Discussion en séance publique`,
248
- uid: `${loiSignet}-${phasePrefix}-DEBATS-SEANCE`,
249
- session: lecAss.session,
250
- chambre: 'SN',
251
- signet_dossier: loiSignet,
252
- code_organisme: null
253
- });
254
- }
255
- }
256
- // =================================================================
257
- // D. DÉCISION / VOTE
258
- // =================================================================
259
- const texteFinal = [...textesTries].reverse().find((t) => {
260
- const origine = (t.origine || "").toLowerCase();
261
- return (origine.includes("adopté") ||
262
- origine.includes("rejeté") ||
263
- origine.includes("devenu résolution") ||
264
- t.code_adoption === "O");
265
- });
266
- if (texteFinal && texteFinal.date) {
267
- const origine = (texteFinal.origine || "").toLowerCase();
268
- let libelleStatut = "Adopté";
269
- if (origine.includes("rejeté")) {
270
- libelleStatut = "Rejeté";
271
- }
272
- else if (origine.includes("devenue résolution")) {
273
- libelleStatut = "Adopté";
274
- }
275
- actes.push({
276
- code_acte: `${phasePrefix}-DEBATS-DEC`,
277
- date: texteFinal.date,
278
- libelle: `${libelleStatut === "Adopté" ? "Adoption" : "Rejet"} (Texte n°${texteFinal.numero})`,
279
- id: texteFinal.id,
280
- numero: texteFinal.numero,
281
- adoption: libelleStatut,
282
- uid: `${loiSignet}-DEC-${texteFinal.numero}`,
283
- session: lecAss.session,
284
- chambre: 'SN',
285
- signet_dossier: loiSignet,
286
- texte_url: texteFinal.url,
287
- code_organisme: null
288
- });
289
- }
290
- }
291
- }
292
- // =================================================================
293
- // E. HORS LECTURE (CC & PROMULGATION)
294
- // =================================================================
295
- if (dossier.date_decision_CoC) {
296
- actes.push({
297
- code_acte: 'CC',
298
- date: dossier.date_decision_CoC,
299
- libelle: `Décision du Conseil constitutionnel`,
300
- id: dossier.url_decision_CoC,
301
- uid: `${loiSignet}-CC`,
302
- chambre: 'AN',
303
- signet_dossier: loiSignet,
304
- texte_url: dossier.url_decision_CoC || dossier.url_dossier_CoC,
305
- });
306
- }
307
- if (dossier.date_promulgation) {
308
- actes.push({
309
- code_acte: 'PROM',
310
- date: dossier.date_promulgation,
311
- libelle: `Promulgation de la loi`,
312
- date_publication_JO: dossier.date_publication_JO,
313
- numero_JO: dossier.numero_JO,
314
- url_legifrance: dossier.url_JO,
315
- id: dossier.url_JO,
316
- uid: `${loiSignet}-PROM`,
317
- chambre: 'AN',
318
- signet_dossier: loiSignet,
319
- });
320
- }
321
- return actes.sort((a, b) => {
322
- const dateA = new Date(a.date).getTime();
323
- const dateB = new Date(b.date).getTime();
324
- return dateA - dateB;
325
- });
326
- }
@@ -1,7 +0,0 @@
1
- export { findAllAmendements } from "./ameli";
2
- export { findAll as findAllDebats } from "./debats";
3
- export { findAllDossiers } from "./dosleg";
4
- export { findAllTextes, findAllRapports } from "./documents";
5
- export { findAllScrutins } from "./scrutins";
6
- export { findAll as findAllQuestions } from "./questions";
7
- export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes } from "./sens";
@@ -1,7 +0,0 @@
1
- export { findAllAmendements } from "./ameli";
2
- export { findAll as findAllDebats } from "./debats";
3
- export { findAllDossiers } from "./dosleg";
4
- export { findAllTextes, findAllRapports } from "./documents";
5
- export { findAllScrutins } from "./scrutins";
6
- export { findAll as findAllQuestions } from "./questions";
7
- export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes } from "./sens";
@@ -1,45 +0,0 @@
1
- import { InferResult } from "kysely";
2
- export type QuestionResult = InferResult<typeof findAllQuery>[0];
3
- declare const findAllQuery: import("kysely").SelectQueryBuilder<{
4
- [x: string]: any;
5
- [x: number]: any;
6
- [x: symbol]: any;
7
- }, "tam_questions" | "sortquestion" | "etatquestion" | "tam_ministeres" | "naturequestion", {
8
- [x: string]: any;
9
- date_publication_JO: string;
10
- ministere_depot: string;
11
- ministere_depot_date_debut: string;
12
- date_transmission: string;
13
- date_reponse_JO: string;
14
- date_erratum_JO: string;
15
- date_cloture: string;
16
- date_signalement: string;
17
- themes: {
18
- libelle: any;
19
- }[];
20
- reponses: {
21
- [x: string]: any;
22
- date_reponse_JO: string;
23
- date_erratum_JO: string;
24
- }[];
25
- }>;
26
- export declare function findAll(): AsyncIterableIterator<{
27
- [x: string]: any;
28
- date_publication_JO: string;
29
- ministere_depot: string;
30
- ministere_depot_date_debut: string;
31
- date_transmission: string;
32
- date_reponse_JO: string;
33
- date_erratum_JO: string;
34
- date_cloture: string;
35
- date_signalement: string;
36
- themes: {
37
- libelle: any;
38
- }[];
39
- reponses: {
40
- [x: string]: any;
41
- date_reponse_JO: string;
42
- date_erratum_JO: string;
43
- }[];
44
- }>;
45
- export {};
@@ -1,89 +0,0 @@
1
- import { jsonArrayFrom } from "kysely/helpers/postgres";
2
- import { dbSenat } from "../databases";
3
- import { expandToRows, rtrim, toDateString } from "./util";
4
- function reponses(questionId) {
5
- return jsonArrayFrom(dbSenat
6
- .withSchema("questions")
7
- .selectFrom("tam_reponses")
8
- .where("tam_reponses.idque", "=", questionId)
9
- .select(({ ref }) => [
10
- toDateString(ref("tam_reponses.datejorep")).as("date_reponse_JO"),
11
- "tam_reponses.pagejorep as page_JO",
12
- toDateString(ref("tam_reponses.errdate")).as("date_erratum_JO"),
13
- "tam_reponses.minreplib as ministere_reponse",
14
- "tam_reponses.minrepid as ministere_reponse_id",
15
- "tam_reponses.urlrep as url",
16
- "tam_reponses.txtrep as texte",
17
- "tam_reponses.txterrrep as texte_erratum",
18
- ])
19
- .orderBy("tam_reponses.datejorep", "asc"));
20
- }
21
- function themes(questionId) {
22
- return jsonArrayFrom(dbSenat
23
- .withSchema("questions")
24
- .with("question_theme", (db) => db
25
- .selectFrom("tam_questions")
26
- .select(({ eb, ref, val }) => [
27
- "id as question_id",
28
- eb.cast(expandToRows(ref("tam_questions.themes"), val("#(\\d+)")), "smallint").as("theme_id"),
29
- ]))
30
- .selectFrom("the")
31
- .leftJoin("question_theme", "the.thenouidt", "question_theme.theme_id")
32
- .where("question_theme.question_id", "=", questionId)
33
- .select("the.thelib as libelle")
34
- .orderBy("the.thenouidt", "asc"));
35
- }
36
- const findAllQuery = dbSenat
37
- .withSchema("questions")
38
- .selectFrom("tam_questions")
39
- .leftJoin("tam_ministeres", "tam_questions.mindepotid", "tam_ministeres.minid")
40
- .leftJoin("sortquestion", (join) => join.onRef("tam_questions.sorquecod", "=", (eb) => eb.cast("sortquestion.sorquecod", "bigint")))
41
- .leftJoin("naturequestion", "tam_questions.natquecod", "naturequestion.natquecod")
42
- .leftJoin("etatquestion", (join) => join.onRef("tam_questions.etaquecod", "=", (eb) => eb.cast("etatquestion.etaquecod", "bigint")))
43
- .select(({ ref }) => [
44
- "tam_questions.repub as republique",
45
- "tam_questions.legislature as legislature",
46
- "tam_questions.natquecod as nature",
47
- "naturequestion.natquelib as nature_libelle",
48
- "tam_questions.numero as numero",
49
- "tam_questions.reference as reference",
50
- "tam_questions.titre as titre",
51
- "tam_questions.nom as nom",
52
- "tam_questions.prenom as prenom",
53
- "tam_questions.nomtechnique as nom_technique",
54
- "tam_questions.codequalite as civilite",
55
- "tam_questions.matricule as matricule",
56
- "tam_questions.cirnum as circonscription_numero",
57
- "tam_questions.circonscription as circonscription",
58
- "tam_questions.groupe as groupe",
59
- "tam_questions.ratgrp as type_appartenance",
60
- toDateString(ref("tam_questions.datejodepot")).as("date_publication_JO"),
61
- "tam_questions.pagejodepot as page_JO",
62
- rtrim(ref("tam_questions.mindepotlib")).as("ministere_depot"),
63
- "tam_questions.mindepotid as ministere_depot_id",
64
- toDateString(ref("tam_ministeres.datedebut")).as("ministere_depot_date_debut"),
65
- toDateString(ref("tam_questions.datejotran")).as("date_transmission"),
66
- "tam_questions.mintranlib as ministere_transmission",
67
- toDateString(ref("tam_questions.datejorep1")).as("date_reponse_JO"),
68
- toDateString(ref("tam_questions.dateerr")).as("date_erratum_JO"),
69
- "tam_questions.pageerr as page_erratum_JO",
70
- "tam_questions.minreplib1 as ministere_reponse",
71
- toDateString(ref("tam_questions.datecloture")).as("date_cloture"),
72
- toDateString(ref("tam_questions.datesignal")).as("date_signalement"),
73
- "tam_questions.refquerappelee as reference_question_rappelee",
74
- //"tam_questions.url as url", // TODO ?
75
- "tam_questions.txtque as texte",
76
- "tam_questions.txterrque as texte_erratum",
77
- "tam_questions.rubrique as rubrique",
78
- "sortquestion.sorquelib as sort",
79
- "sortquestion.sorquecod as sort_code",
80
- "sortquestion.sorquenumtri as sort_tri",
81
- "etatquestion.etaquelib as etat_libelle",
82
- "etatquestion.etaquecod as etat_code",
83
- "etatquestion.etaquenumtri as etat_tri",
84
- themes(ref("tam_questions.id")).as("themes"),
85
- reponses(ref("tam_questions.id")).as("reponses"),
86
- ]);
87
- export function findAll() {
88
- return findAllQuery.stream();
89
- }
@@ -1,13 +0,0 @@
1
- import { InferResult } from "kysely";
2
- export type ScrutinResult = InferResult<typeof findAllScrutinsQuery>[0];
3
- declare const findAllScrutinsQuery: import("kysely").SelectQueryBuilder<{
4
- [x: string]: any;
5
- [x: number]: any;
6
- [x: symbol]: any;
7
- }, "date_seance" | "lecass" | "lecture" | "loi" | "scr" | "typlec", {
8
- [x: string]: any;
9
- }>;
10
- export declare function findAllScrutins(fromSession?: number): AsyncIterableIterator<{
11
- [x: string]: any;
12
- }>;
13
- export {};
@@ -1,114 +0,0 @@
1
- import { sql } from "kysely";
2
- import { jsonArrayFrom } from "kysely/helpers/postgres";
3
- import { dbSenat } from "../databases";
4
- import { rtrim, toDateString } from "./util";
5
- function votes(scrutinNum, scrutinSession, scrutinDate) {
6
- return jsonArrayFrom(dbSenat
7
- .selectFrom("dosleg.votsen")
8
- .leftJoin("dosleg.titsen", "dosleg.titsen.titsencod", "dosleg.votsen.titsencod")
9
- .leftJoin("dosleg.stavot", "dosleg.stavot.stavotidt", "dosleg.votsen.stavotidt")
10
- .leftJoin("dosleg.posvot", "dosleg.posvot.posvotcod", "dosleg.votsen.posvotcod")
11
- .leftJoin("sens.memgrppol", (join) => join
12
- .onRef("sens.memgrppol.senmat", "=", "dosleg.votsen.senmat")
13
- .onRef("sens.memgrppol.memgrppoldatdeb", "<=", scrutinDate)
14
- .on((eb) => eb.or([
15
- eb("sens.memgrppol.memgrppoldatfin", ">=", scrutinDate),
16
- eb("sens.memgrppol.memgrppoldatfin", "is", null),
17
- ])))
18
- .where("dosleg.votsen.scrnum", "=", scrutinNum)
19
- .where("dosleg.votsen.sesann", "=", scrutinSession)
20
- .orderBy("sens.memgrppol.memgrppoldatdeb", "desc")
21
- .select([
22
- "dosleg.votsen.senmat as matricule_votant",
23
- "dosleg.votsen.senmatdel as matricule_delegant",
24
- "dosleg.posvot.posvotlib as position",
25
- "dosleg.stavot.stavotlib as statut_votant",
26
- "dosleg.titsen.titsenlib as titre_votant",
27
- "sens.memgrppol.memgrppolid as groupe_politique_id",
28
- "sens.memgrppol.grppolcod as groupe_politique_code",
29
- ]));
30
- }
31
- function groupesVotants(scrutinNum, scrutinSession, scrutinDate) {
32
- return jsonArrayFrom(dbSenat
33
- .selectFrom((eb) => eb
34
- .selectFrom("dosleg.votsen")
35
- .leftJoin("dosleg.posvot", "dosleg.posvot.posvotcod", "dosleg.votsen.posvotcod")
36
- .leftJoin("dosleg.stavot", "dosleg.stavot.stavotidt", "dosleg.votsen.stavotidt")
37
- .leftJoin("sens.memgrppol", (join) => join
38
- .onRef("sens.memgrppol.senmat", "=", "dosleg.votsen.senmat")
39
- .onRef("sens.memgrppol.memgrppoldatdeb", "<=", scrutinDate)
40
- .on((eb) => eb.or([
41
- eb("sens.memgrppol.memgrppoldatfin", ">=", scrutinDate),
42
- eb("sens.memgrppol.memgrppoldatfin", "is", null),
43
- ])))
44
- .where("dosleg.votsen.scrnum", "=", scrutinNum)
45
- .where("dosleg.votsen.sesann", "=", scrutinSession)
46
- .orderBy("sens.memgrppol.memgrppoldatdeb", "desc")
47
- .select([
48
- "dosleg.votsen.senmat",
49
- "dosleg.posvot.posvotlib",
50
- "dosleg.stavot.stavotlib",
51
- "sens.memgrppol.grppolcod",
52
- ])
53
- .as("unique_votes"))
54
- .groupBy(["unique_votes.grppolcod"])
55
- .select(({ fn, eb }) => [
56
- "unique_votes.grppolcod as groupe_politique_code",
57
- fn.sum(eb.case().when("unique_votes.posvotlib", "=", "pour").then(1).else(0).end()).as("nombre_pour"),
58
- fn.sum(eb.case().when("unique_votes.posvotlib", "=", "contre").then(1).else(0).end()).as("nombre_contre"),
59
- fn
60
- .sum(eb.case().when("unique_votes.posvotlib", "=", "abstention").then(1).else(0).end())
61
- .as("nombre_abstentions"),
62
- fn
63
- .sum(eb.case().when("unique_votes.posvotlib", "=", "non-votant").then(1).else(0).end())
64
- .as("nombre_non_votants"),
65
- fn.count("unique_votes.senmat").as("nombre_votants"),
66
- ]));
67
- }
68
- function misesAuPoint(scrutinNum) {
69
- return jsonArrayFrom(dbSenat
70
- .withSchema("dosleg")
71
- .selectFrom("corscr")
72
- .where("corscr.scrnum", "=", scrutinNum)
73
- .select(["corscr.corscrtxt as texte", "corscr.corscrord as ordre", "corscr.corscrurl as url"]));
74
- }
75
- const findAllScrutinsQuery = dbSenat
76
- .withSchema("dosleg")
77
- .selectFrom("scr")
78
- .leftJoin("date_seance", "scr.code", "date_seance.code")
79
- .leftJoin("lecass", "date_seance.lecidt", "lecass.lecassidt")
80
- .leftJoin("lecture", "lecture.lecidt", "lecass.lecidt")
81
- .leftJoin("loi", "loi.loicod", "lecture.loicod")
82
- .leftJoin("typlec", "typlec.typleccod", "lecture.typleccod")
83
- .select(({ eb, ref, val }) => [
84
- "scr.sesann as session",
85
- "scr.scrnum as numero",
86
- rtrim(ref("date_seance.lecidt")).as("lecture_id"),
87
- rtrim(ref("lecture.leccom")).as("lecture_libelle"),
88
- "loi.signet as signet_dossier",
89
- rtrim(ref("typlec.typleclib")).as("type_lecture"),
90
- toDateString(ref("scr.scrdat")).as("date_scrutin"),
91
- toDateString(ref("scr.scrdateff")).as("date_scrutin_effective"),
92
- sql `REPLACE(scr.scrint, E'\\u0092', '''')`.as("intitule"),
93
- "scr.scrbaspag as note",
94
- "scr.scrmaj as nombre_majorite",
95
- "scr.scrmajsea as nombre_majorite_seance",
96
- "scr.scrvot as nombre_votants",
97
- "scr.scrvotsea as nombre_votants_seance",
98
- "scr.scrsuf as nombre_suffrages",
99
- "scr.scrsufsea as nombre_suffrages_seance",
100
- "scr.scrcon as nombre_contre",
101
- "scr.scrconsea as nombre_contre_seance",
102
- "scr.scrpou as nombre_pour",
103
- "scr.scrpousea as nombre_pour_seance",
104
- votes(ref("scr.scrnum"), ref("scr.sesann"), ref("scr.scrdat")).as("votes"),
105
- groupesVotants(ref("scr.scrnum"), ref("scr.sesann"), ref("scr.scrdat")).as("groupes_votants"),
106
- misesAuPoint(ref("scr.scrnum")).as("mises_au_point"),
107
- ])
108
- .$narrowType();
109
- export function findAllScrutins(fromSession) {
110
- if (fromSession !== undefined) {
111
- return findAllScrutinsQuery.where("scr.sesann", ">=", fromSession).stream();
112
- }
113
- return findAllScrutinsQuery.stream();
114
- }
@@ -1,3 +0,0 @@
1
- import { CompteRendu } from "../types/compte_rendu";
2
- export declare function parseCompteRenduIntervalFromFile(xmlFilePath: string, startIndex: number, endIndex: number, agendaEventId: string): Promise<CompteRendu | null>;
3
- export declare function sessionStartYearFromDate(d: Date): number;