@tricoteuses/senat 2.22.16 → 3.0.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.
Files changed (345) hide show
  1. package/README.md +168 -0
  2. package/lib/aggregates.d.ts +52 -0
  3. package/lib/aggregates.js +930 -0
  4. package/lib/aggregates.mjs +713 -0
  5. package/lib/aggregates.ts +833 -0
  6. package/lib/config.d.ts +10 -0
  7. package/lib/config.js +16 -0
  8. package/lib/config.mjs +16 -0
  9. package/lib/config.ts +26 -0
  10. package/lib/databases.d.ts +2 -0
  11. package/lib/databases.js +26 -0
  12. package/lib/databases.mjs +57 -0
  13. package/lib/databases.ts +71 -0
  14. package/lib/datasets.d.ts +34 -0
  15. package/lib/datasets.js +233 -0
  16. package/lib/datasets.mjs +78 -0
  17. package/lib/datasets.ts +118 -0
  18. package/lib/fields.d.ts +10 -0
  19. package/lib/fields.js +68 -0
  20. package/lib/fields.mjs +22 -0
  21. package/lib/fields.ts +29 -0
  22. package/lib/git.d.ts +26 -0
  23. package/lib/git.js +167 -0
  24. package/lib/index.d.ts +13 -0
  25. package/lib/index.js +1 -0
  26. package/lib/index.mjs +7 -0
  27. package/lib/index.ts +64 -0
  28. package/lib/inserters.d.ts +98 -0
  29. package/lib/inserters.js +500 -0
  30. package/lib/inserters.mjs +360 -0
  31. package/lib/inserters.ts +521 -0
  32. package/lib/legislatures.json +38 -0
  33. package/lib/loaders.d.ts +58 -0
  34. package/lib/loaders.js +286 -0
  35. package/lib/loaders.mjs +158 -0
  36. package/lib/loaders.ts +271 -0
  37. package/lib/model/agenda.d.ts +6 -0
  38. package/lib/model/agenda.js +148 -0
  39. package/lib/model/ameli.d.ts +51 -0
  40. package/lib/model/ameli.js +149 -0
  41. package/lib/model/ameli.mjs +84 -0
  42. package/lib/model/ameli.ts +100 -0
  43. package/lib/model/commission.d.ts +18 -0
  44. package/lib/model/commission.js +269 -0
  45. package/lib/model/debats.d.ts +67 -0
  46. package/lib/model/debats.js +95 -0
  47. package/lib/model/debats.mjs +43 -0
  48. package/lib/model/debats.ts +68 -0
  49. package/lib/model/documents.d.ts +12 -0
  50. package/lib/model/documents.js +151 -0
  51. package/lib/model/dosleg.d.ts +7 -0
  52. package/lib/model/dosleg.js +326 -0
  53. package/lib/model/dosleg.mjs +196 -0
  54. package/lib/model/dosleg.ts +240 -0
  55. package/lib/model/index.d.ts +7 -0
  56. package/lib/model/index.js +7 -0
  57. package/lib/model/index.mjs +5 -0
  58. package/lib/model/index.ts +15 -0
  59. package/lib/model/questions.d.ts +45 -0
  60. package/lib/model/questions.js +89 -0
  61. package/lib/model/questions.mjs +71 -0
  62. package/lib/model/questions.ts +93 -0
  63. package/lib/model/scrutins.d.ts +13 -0
  64. package/lib/model/scrutins.js +114 -0
  65. package/lib/model/seance.d.ts +3 -0
  66. package/lib/model/seance.js +267 -0
  67. package/lib/model/sens.d.ts +146 -0
  68. package/lib/model/sens.js +454 -0
  69. package/lib/model/sens.mjs +415 -0
  70. package/lib/model/sens.ts +516 -0
  71. package/lib/model/texte.d.ts +7 -0
  72. package/lib/model/texte.js +256 -0
  73. package/lib/model/texte.mjs +208 -0
  74. package/lib/model/texte.ts +229 -0
  75. package/lib/model/util.d.ts +9 -0
  76. package/lib/model/util.js +38 -0
  77. package/lib/model/util.mjs +19 -0
  78. package/lib/model/util.ts +32 -0
  79. package/lib/parsers/texte.d.ts +7 -0
  80. package/lib/parsers/texte.js +228 -0
  81. package/lib/raw_types/ameli.d.ts +914 -0
  82. package/lib/raw_types/ameli.js +5 -0
  83. package/lib/raw_types/ameli.mjs +163 -0
  84. package/lib/raw_types/debats.d.ts +207 -0
  85. package/lib/raw_types/debats.js +5 -0
  86. package/lib/raw_types/debats.mjs +58 -0
  87. package/lib/raw_types/dosleg.d.ts +1619 -0
  88. package/lib/raw_types/dosleg.js +5 -0
  89. package/lib/raw_types/dosleg.mjs +438 -0
  90. package/lib/raw_types/questions.d.ts +419 -0
  91. package/lib/raw_types/questions.js +5 -0
  92. package/lib/raw_types/questions.mjs +11 -0
  93. package/lib/raw_types/senat.d.ts +11368 -0
  94. package/lib/raw_types/senat.js +5 -0
  95. package/lib/raw_types/sens.d.ts +8248 -0
  96. package/lib/raw_types/sens.js +5 -0
  97. package/lib/raw_types/sens.mjs +508 -0
  98. package/lib/raw_types_kysely/ameli.d.ts +915 -0
  99. package/lib/raw_types_kysely/ameli.js +7 -0
  100. package/lib/raw_types_kysely/ameli.mjs +5 -0
  101. package/lib/raw_types_kysely/ameli.ts +951 -0
  102. package/lib/raw_types_kysely/debats.d.ts +207 -0
  103. package/lib/raw_types_kysely/debats.js +7 -0
  104. package/lib/raw_types_kysely/debats.mjs +5 -0
  105. package/lib/raw_types_kysely/debats.ts +222 -0
  106. package/lib/raw_types_kysely/dosleg.d.ts +3532 -0
  107. package/lib/raw_types_kysely/dosleg.js +7 -0
  108. package/lib/raw_types_kysely/dosleg.mjs +5 -0
  109. package/lib/raw_types_kysely/dosleg.ts +3621 -0
  110. package/lib/raw_types_kysely/questions.d.ts +414 -0
  111. package/lib/raw_types_kysely/questions.js +7 -0
  112. package/lib/raw_types_kysely/questions.mjs +5 -0
  113. package/lib/raw_types_kysely/questions.ts +426 -0
  114. package/lib/raw_types_kysely/sens.d.ts +4394 -0
  115. package/lib/raw_types_kysely/sens.js +7 -0
  116. package/lib/raw_types_kysely/sens.mjs +5 -0
  117. package/lib/raw_types_kysely/sens.ts +4499 -0
  118. package/lib/raw_types_schemats/ameli.d.ts +539 -0
  119. package/lib/raw_types_schemats/ameli.js +2 -0
  120. package/lib/raw_types_schemats/ameli.mjs +2 -0
  121. package/lib/raw_types_schemats/ameli.ts +601 -0
  122. package/lib/raw_types_schemats/debats.d.ts +127 -0
  123. package/lib/raw_types_schemats/debats.js +2 -0
  124. package/lib/raw_types_schemats/debats.mjs +2 -0
  125. package/lib/raw_types_schemats/debats.ts +145 -0
  126. package/lib/raw_types_schemats/dosleg.d.ts +977 -0
  127. package/lib/raw_types_schemats/dosleg.js +2 -0
  128. package/lib/raw_types_schemats/dosleg.mjs +2 -0
  129. package/lib/raw_types_schemats/dosleg.ts +2193 -0
  130. package/lib/raw_types_schemats/questions.d.ts +235 -0
  131. package/lib/raw_types_schemats/questions.js +2 -0
  132. package/lib/raw_types_schemats/questions.mjs +2 -0
  133. package/lib/raw_types_schemats/questions.ts +249 -0
  134. package/lib/raw_types_schemats/sens.d.ts +6915 -0
  135. package/lib/raw_types_schemats/sens.js +2 -0
  136. package/lib/raw_types_schemats/sens.mjs +2 -0
  137. package/lib/raw_types_schemats/sens.ts +2907 -0
  138. package/lib/scripts/convert_data.d.ts +1 -0
  139. package/lib/scripts/convert_data.js +354 -0
  140. package/lib/scripts/convert_data.mjs +181 -0
  141. package/lib/scripts/convert_data.ts +243 -0
  142. package/lib/scripts/data-download.d.ts +1 -0
  143. package/lib/scripts/data-download.js +12 -0
  144. package/lib/scripts/datautil.d.ts +8 -0
  145. package/lib/scripts/datautil.js +34 -0
  146. package/lib/scripts/datautil.mjs +16 -0
  147. package/lib/scripts/datautil.ts +19 -0
  148. package/lib/scripts/images/transparent_150x192.jpg +0 -0
  149. package/lib/scripts/images/transparent_155x225.jpg +0 -0
  150. package/lib/scripts/parse_textes.d.ts +1 -0
  151. package/lib/scripts/parse_textes.js +44 -0
  152. package/lib/scripts/parse_textes.mjs +46 -0
  153. package/lib/scripts/parse_textes.ts +65 -0
  154. package/lib/scripts/retrieve_agenda.d.ts +1 -0
  155. package/lib/scripts/retrieve_agenda.js +132 -0
  156. package/lib/scripts/retrieve_cr_commission.d.ts +1 -0
  157. package/lib/scripts/retrieve_cr_commission.js +364 -0
  158. package/lib/scripts/retrieve_cr_seance.d.ts +6 -0
  159. package/lib/scripts/retrieve_cr_seance.js +347 -0
  160. package/lib/scripts/retrieve_documents.d.ts +3 -0
  161. package/lib/scripts/retrieve_documents.js +219 -0
  162. package/lib/scripts/retrieve_documents.mjs +249 -0
  163. package/lib/scripts/retrieve_documents.ts +298 -0
  164. package/lib/scripts/retrieve_open_data.d.ts +1 -0
  165. package/lib/scripts/retrieve_open_data.js +315 -0
  166. package/lib/scripts/retrieve_open_data.mjs +217 -0
  167. package/lib/scripts/retrieve_open_data.ts +268 -0
  168. package/lib/scripts/retrieve_senateurs_photos.d.ts +1 -0
  169. package/lib/scripts/retrieve_senateurs_photos.js +147 -0
  170. package/lib/scripts/retrieve_senateurs_photos.mjs +147 -0
  171. package/lib/scripts/retrieve_senateurs_photos.ts +177 -0
  172. package/lib/scripts/retrieve_videos.d.ts +1 -0
  173. package/lib/scripts/retrieve_videos.js +461 -0
  174. package/lib/scripts/shared/cli_helpers.d.ts +95 -0
  175. package/lib/scripts/shared/cli_helpers.js +91 -0
  176. package/lib/scripts/shared/cli_helpers.ts +36 -0
  177. package/lib/scripts/shared/util.d.ts +4 -0
  178. package/lib/scripts/shared/util.js +35 -0
  179. package/lib/scripts/shared/util.ts +33 -0
  180. package/lib/scripts/test_iter_load.d.ts +1 -0
  181. package/lib/scripts/test_iter_load.js +12 -0
  182. package/lib/src/config.d.ts +22 -0
  183. package/lib/src/config.js +17 -7
  184. package/lib/src/conversion_textes.js +5 -1
  185. package/lib/src/databases.d.ts +2 -1
  186. package/lib/src/databases_postgres.d.ts +4 -0
  187. package/lib/src/databases_postgres.js +23 -0
  188. package/lib/src/datasets.d.ts +4 -0
  189. package/lib/src/datasets.js +16 -2
  190. package/lib/src/git.d.ts +1 -0
  191. package/lib/src/git.js +45 -11
  192. package/lib/src/index.d.ts +19 -8
  193. package/lib/src/index.js +6 -1
  194. package/lib/src/loaders.js +10 -4
  195. package/lib/src/model/agenda.js +2 -2
  196. package/lib/src/model/ameli.d.ts +64 -52
  197. package/lib/src/model/ameli.js +147 -145
  198. package/lib/src/model/ameli_postgres.d.ts +67 -0
  199. package/lib/src/model/ameli_postgres.js +150 -0
  200. package/lib/src/model/commission.d.ts +3 -2
  201. package/lib/src/model/commission.js +2 -2
  202. package/lib/src/model/debats.d.ts +38 -66
  203. package/lib/src/model/debats.js +110 -93
  204. package/lib/src/model/documents.d.ts +32 -12
  205. package/lib/src/model/documents.js +171 -130
  206. package/lib/src/model/dosleg.d.ts +142 -5
  207. package/lib/src/model/dosleg.js +298 -156
  208. package/lib/src/model/questions.d.ts +54 -45
  209. package/lib/src/model/questions.js +89 -87
  210. package/lib/src/model/scrutins.d.ts +48 -13
  211. package/lib/src/model/scrutins.js +118 -111
  212. package/lib/src/model/seance.js +3 -3
  213. package/lib/src/model/sens.d.ts +109 -179
  214. package/lib/src/model/sens.js +384 -484
  215. package/lib/src/model/util.d.ts +0 -8
  216. package/lib/src/model/util.js +0 -23
  217. package/lib/src/parsers/texte.js +7 -7
  218. package/lib/src/raw_types/ameli.d.ts +1651 -803
  219. package/lib/src/raw_types/ameli.js +1816 -5
  220. package/lib/src/raw_types/debats.d.ts +353 -180
  221. package/lib/src/raw_types/debats.js +517 -5
  222. package/lib/src/raw_types/dosleg.d.ts +2862 -1527
  223. package/lib/src/raw_types/dosleg.js +4354 -5
  224. package/lib/src/raw_types/questions.d.ts +671 -395
  225. package/lib/src/raw_types/questions.js +1303 -5
  226. package/lib/src/raw_types/sens.d.ts +7743 -8148
  227. package/lib/src/raw_types/sens.js +10429 -5
  228. package/lib/src/raw_types_schemats/ameli.d.ts +4 -2
  229. package/lib/src/raw_types_schemats/debats.d.ts +2 -2
  230. package/lib/src/raw_types_schemats/dosleg.d.ts +2 -2
  231. package/lib/src/raw_types_schemats/questions.d.ts +2 -2
  232. package/lib/src/raw_types_schemats/sens.d.ts +10 -4216
  233. package/lib/src/scripts/convert_data.js +7 -6
  234. package/lib/src/scripts/convert_xml_to_html.js +2 -2
  235. package/lib/src/scripts/data-download.js +3 -2
  236. package/lib/src/scripts/retrieve_agenda.js +21 -9
  237. package/lib/src/scripts/retrieve_cr_commission.js +17 -17
  238. package/lib/src/scripts/retrieve_cr_seance.d.ts +14 -1
  239. package/lib/src/scripts/retrieve_cr_seance.js +10 -11
  240. package/lib/src/scripts/retrieve_documents.d.ts +11 -2
  241. package/lib/src/scripts/retrieve_documents.js +25 -14
  242. package/lib/src/scripts/retrieve_open_data.js +514 -153
  243. package/lib/src/scripts/retrieve_senateurs_photos.js +25 -11
  244. package/lib/src/scripts/retrieve_videos.js +12 -11
  245. package/lib/src/scripts/shared/cli_helpers.d.ts +1 -6
  246. package/lib/src/scripts/shared/cli_helpers.js +9 -8
  247. package/lib/src/scripts/shared/incremental_import_sql.d.ts +2 -0
  248. package/lib/src/scripts/shared/incremental_import_sql.js +894 -0
  249. package/lib/src/scripts/shared/prefixed_tables.d.ts +10 -0
  250. package/lib/src/scripts/shared/prefixed_tables.js +36 -0
  251. package/lib/src/scripts/shared/schema_version.d.ts +3 -0
  252. package/lib/src/scripts/shared/schema_version.js +97 -0
  253. package/lib/src/scripts/shared/staging_import.d.ts +3 -0
  254. package/lib/src/scripts/shared/staging_import.js +80 -0
  255. package/lib/src/scripts/shared/staging_metadata_sql.d.ts +1 -0
  256. package/lib/src/scripts/shared/staging_metadata_sql.js +221 -0
  257. package/lib/src/scripts/validate_prefixed_tables.d.ts +1 -0
  258. package/lib/src/scripts/validate_prefixed_tables.js +101 -0
  259. package/lib/src/types/ameli.d.ts +4 -4
  260. package/lib/src/types/debats.d.ts +2 -2
  261. package/lib/src/types/dosleg.d.ts +39 -39
  262. package/lib/src/types/questions.d.ts +2 -2
  263. package/lib/src/types/sens.d.ts +0 -2
  264. package/lib/src/types/texte.d.ts +1 -1
  265. package/lib/src/utils/cr_spliting.d.ts +9 -6
  266. package/lib/src/utils/cr_spliting.js +6 -101
  267. package/lib/src/utils/reunion_odj_building.d.ts +7 -3
  268. package/lib/src/utils/reunion_parsing.d.ts +2 -1
  269. package/lib/src/utils/reunion_parsing.js +2 -2
  270. package/lib/src/videos/match.js +8 -5
  271. package/lib/src/videos/pipeline.d.ts +6 -2
  272. package/lib/src/videos/pipeline.js +21 -8
  273. package/lib/src/videos/search.js +6 -2
  274. package/lib/strings.d.ts +1 -0
  275. package/lib/strings.js +18 -0
  276. package/lib/strings.mjs +18 -0
  277. package/lib/strings.ts +26 -0
  278. package/lib/tests/incrementalImportSql.test.d.ts +1 -0
  279. package/lib/tests/incrementalImportSql.test.js +155 -0
  280. package/lib/tests/prefixedTables.test.d.ts +1 -0
  281. package/lib/tests/prefixedTables.test.js +22 -0
  282. package/lib/tests/schemaVersion.test.d.ts +1 -0
  283. package/lib/tests/schemaVersion.test.js +23 -0
  284. package/lib/tests/validatePrefixedTables.test.d.ts +1 -0
  285. package/lib/tests/validatePrefixedTables.test.js +14 -0
  286. package/lib/types/agenda.d.ts +44 -0
  287. package/lib/types/agenda.js +1 -0
  288. package/lib/types/ameli.d.ts +5 -0
  289. package/lib/types/ameli.js +1 -0
  290. package/lib/types/ameli.mjs +13 -0
  291. package/lib/types/ameli.ts +21 -0
  292. package/lib/types/compte_rendu.d.ts +83 -0
  293. package/lib/types/compte_rendu.js +1 -0
  294. package/lib/types/debats.d.ts +2 -0
  295. package/lib/types/debats.js +1 -0
  296. package/lib/types/debats.mjs +2 -0
  297. package/lib/types/debats.ts +6 -0
  298. package/lib/types/dosleg.d.ts +70 -0
  299. package/lib/types/dosleg.js +1 -0
  300. package/lib/types/dosleg.mjs +151 -0
  301. package/lib/types/dosleg.ts +284 -0
  302. package/lib/types/questions.d.ts +2 -0
  303. package/lib/types/questions.js +1 -0
  304. package/lib/types/questions.mjs +1 -0
  305. package/lib/types/questions.ts +3 -0
  306. package/lib/types/sens.d.ts +10 -0
  307. package/lib/types/sens.js +1 -0
  308. package/lib/types/sens.mjs +1 -0
  309. package/lib/types/sens.ts +12 -0
  310. package/lib/types/sessions.d.ts +5 -0
  311. package/lib/types/sessions.js +84 -0
  312. package/lib/types/sessions.mjs +43 -0
  313. package/lib/types/sessions.ts +42 -0
  314. package/lib/types/texte.d.ts +74 -0
  315. package/lib/types/texte.js +16 -0
  316. package/lib/types/texte.mjs +16 -0
  317. package/lib/types/texte.ts +76 -0
  318. package/lib/typings/windows-1252.d.js +2 -0
  319. package/lib/typings/windows-1252.d.mjs +2 -0
  320. package/lib/typings/windows-1252.d.ts +11 -0
  321. package/lib/utils/cr_spliting.d.ts +28 -0
  322. package/lib/utils/cr_spliting.js +265 -0
  323. package/lib/utils/date.d.ts +10 -0
  324. package/lib/utils/date.js +100 -0
  325. package/lib/utils/nvs-timecode.d.ts +7 -0
  326. package/lib/utils/nvs-timecode.js +79 -0
  327. package/lib/utils/reunion_grouping.d.ts +9 -0
  328. package/lib/utils/reunion_grouping.js +361 -0
  329. package/lib/utils/reunion_odj_building.d.ts +5 -0
  330. package/lib/utils/reunion_odj_building.js +154 -0
  331. package/lib/utils/reunion_parsing.d.ts +23 -0
  332. package/lib/utils/reunion_parsing.js +209 -0
  333. package/lib/utils/scoring.d.ts +14 -0
  334. package/lib/utils/scoring.js +147 -0
  335. package/lib/utils/string_cleaning.d.ts +7 -0
  336. package/lib/utils/string_cleaning.js +57 -0
  337. package/lib/validators/config.d.ts +9 -0
  338. package/lib/validators/config.js +10 -0
  339. package/lib/validators/config.mjs +54 -0
  340. package/lib/validators/config.ts +79 -0
  341. package/lib/validators/senat.d.ts +0 -0
  342. package/lib/validators/senat.js +28 -0
  343. package/lib/validators/senat.mjs +24 -0
  344. package/lib/validators/senat.ts +26 -0
  345. package/package.json +11 -11
@@ -1,45 +1,54 @@
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
+ export interface QuestionReponseRow {
2
+ date_erratum_JO: string | null;
3
+ date_reponse_JO: string | null;
4
+ ministere_reponse: string | null;
5
+ ministere_reponse_id: string | null;
6
+ page_JO: string | null;
7
+ texte: string | null;
8
+ texte_erratum: string | null;
9
+ url: string | null;
10
+ }
11
+ export interface QuestionResult {
12
+ circonscription: string | null;
13
+ circonscription_numero: string | null;
14
+ civilite: string | null;
15
+ date_cloture: string | null;
16
+ date_erratum_JO: string | null;
17
+ date_publication_JO: string | null;
18
+ date_reponse_JO: string | null;
19
+ date_signalement: string | null;
20
+ date_transmission: string | null;
21
+ etat_code: string | null;
22
+ etat_libelle: string | null;
23
+ etat_tri: string | null;
24
+ groupe: string | null;
25
+ legislature: string | null;
26
+ matricule: string;
27
+ ministere_depot: string | null;
28
+ ministere_depot_date_debut: string | null;
29
+ ministere_depot_id: string | null;
30
+ ministere_reponse: string | null;
31
+ ministere_transmission: string | null;
32
+ nature: string | null;
33
+ nature_libelle: string | null;
34
+ nom: string | null;
35
+ nom_technique: string | null;
36
+ numero: string | null;
37
+ page_JO: string | null;
38
+ page_erratum_JO: string | null;
39
+ prenom: string | null;
40
+ reference: string | null;
41
+ reference_question_rappelee: string | null;
42
+ republique: string | null;
43
+ reponses: QuestionReponseRow[];
44
+ rubrique: string | null;
45
+ sort: string | null;
46
+ sort_code: string | null;
47
+ sort_tri: string | null;
48
+ texte: string | null;
49
+ texte_erratum: string | null;
50
+ themes: string[];
51
+ titre: string | null;
52
+ type_appartenance: string | null;
53
+ }
54
+ export declare function findAll(): AsyncGenerator<QuestionResult, void, unknown>;
@@ -1,89 +1,91 @@
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"));
1
+ import { streamUnsafeQuery } from "../databases_postgres";
2
+ function buildFindAllQuestionsQuery() {
3
+ return {
4
+ params: [],
5
+ query: `
6
+ select
7
+ tam_questions.repub::text as republique,
8
+ tam_questions.legislature::text as legislature,
9
+ tam_questions.natquecod as nature,
10
+ naturequestion.natquelib as nature_libelle,
11
+ tam_questions.numero as numero,
12
+ tam_questions.reference as reference,
13
+ tam_questions.titre as titre,
14
+ tam_questions.nom as nom,
15
+ tam_questions.prenom as prenom,
16
+ tam_questions.nomtechnique as nom_technique,
17
+ tam_questions.codequalite as civilite,
18
+ tam_questions.matricule as matricule,
19
+ tam_questions.cirnum::text as circonscription_numero,
20
+ tam_questions.circonscription as circonscription,
21
+ tam_questions.groupe as groupe,
22
+ tam_questions.ratgrp as type_appartenance,
23
+ to_char(tam_questions.datejodepot, 'YYYY-MM-DD') as date_publication_JO,
24
+ tam_questions.pagejodepot::text as page_JO,
25
+ rtrim(tam_questions.mindepotlib) as ministere_depot,
26
+ tam_questions.mindepotid::text as ministere_depot_id,
27
+ to_char(tam_ministeres.datedebut, 'YYYY-MM-DD') as ministere_depot_date_debut,
28
+ to_char(tam_questions.datejotran, 'YYYY-MM-DD') as date_transmission,
29
+ tam_questions.mintranlib as ministere_transmission,
30
+ to_char(tam_questions.datejorep1, 'YYYY-MM-DD') as date_reponse_JO,
31
+ to_char(tam_questions.dateerr, 'YYYY-MM-DD') as date_erratum_JO,
32
+ tam_questions.pageerr::text as page_erratum_JO,
33
+ tam_questions.minreplib1 as ministere_reponse,
34
+ to_char(tam_questions.datecloture, 'YYYY-MM-DD') as date_cloture,
35
+ to_char(tam_questions.datesignal, 'YYYY-MM-DD') as date_signalement,
36
+ tam_questions.refquerappelee as reference_question_rappelee,
37
+ tam_questions.txtque as texte,
38
+ tam_questions.txterrque as texte_erratum,
39
+ tam_questions.rubrique as rubrique,
40
+ sortquestion.sorquelib as sort,
41
+ sortquestion.sorquecod as sort_code,
42
+ sortquestion.sorquenumtri::text as sort_tri,
43
+ etatquestion.etaquelib as etat_libelle,
44
+ etatquestion.etaquecod as etat_code,
45
+ etatquestion.etaquenumtri::text as etat_tri,
46
+ (
47
+ select coalesce(json_agg(theme_rows.libelle order by theme_rows.theme_order nulls last), '[]'::json)
48
+ from (
49
+ select
50
+ the.thelib as libelle,
51
+ the.thenouidt as theme_order
52
+ from regexp_matches(coalesce(tam_questions.themes, ''), '#(\\d+)', 'g') as matches(match)
53
+ join senat.questions_the as the on the.thenouidt::text = matches.match[1]
54
+ order by the.thenouidt asc
55
+ ) as theme_rows
56
+ ) as themes,
57
+ (
58
+ select coalesce(json_agg(response_rows order by response_rows.date_reponse_JO nulls last), '[]'::json)
59
+ from (
60
+ select
61
+ to_char(tam_reponses.datejorep, 'YYYY-MM-DD') as date_reponse_JO,
62
+ tam_reponses.pagejorep::text as page_JO,
63
+ to_char(tam_reponses.errdate, 'YYYY-MM-DD') as date_erratum_JO,
64
+ tam_reponses.minreplib as ministere_reponse,
65
+ tam_reponses.minrepid::text as ministere_reponse_id,
66
+ tam_reponses.urlrep as url,
67
+ tam_reponses.txtrep as texte,
68
+ tam_reponses.txterrrep as texte_erratum
69
+ from senat.questions_tam_reponses as tam_reponses
70
+ where tam_reponses.idque = tam_questions.id
71
+ order by tam_reponses.datejorep asc
72
+ ) as response_rows
73
+ ) as reponses
74
+ from senat.questions_tam_questions as tam_questions
75
+ left join senat.questions_tam_ministeres as tam_ministeres on tam_questions.mindepotid = tam_ministeres.minid
76
+ left join senat.questions_sortquestion as sortquestion on tam_questions.sorquecod::text = sortquestion.sorquecod
77
+ left join senat.questions_naturequestion as naturequestion on tam_questions.natquecod = naturequestion.natquecod
78
+ left join senat.questions_etatquestion as etatquestion on tam_questions.etaquecod::text = etatquestion.etaquecod
79
+ `,
80
+ };
20
81
  }
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();
82
+ export async function* findAll() {
83
+ const { query, params } = buildFindAllQuestionsQuery();
84
+ for await (const row of streamUnsafeQuery(query, params)) {
85
+ yield {
86
+ ...row,
87
+ reponses: row.reponses ?? [],
88
+ themes: row.themes ?? [],
89
+ };
90
+ }
89
91
  }
@@ -1,13 +1,48 @@
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
+ export interface VoteScrutinRow {
2
+ groupe_politique_code: string | null;
3
+ groupe_politique_id: string | null;
4
+ matricule_delegant: string | null;
5
+ matricule_votant: string;
6
+ position: string | null;
7
+ statut_votant: string | null;
8
+ titre_votant: string | null;
9
+ }
10
+ export interface GroupeVotantRow {
11
+ groupe_politique_code: string | null;
12
+ nombre_abstentions: string;
13
+ nombre_contre: string;
14
+ nombre_non_votants: string;
15
+ nombre_pour: string;
16
+ nombre_votants: string;
17
+ }
18
+ export interface MiseAuPointRow {
19
+ ordre: string | null;
20
+ texte: string;
21
+ url: string | null;
22
+ }
23
+ export interface ScrutinResult {
24
+ date_scrutin: string | null;
25
+ date_scrutin_effective: string | null;
26
+ groupes_votants: GroupeVotantRow[];
27
+ intitule: string | null;
28
+ lecture_id: string | null;
29
+ lecture_libelle: string | null;
30
+ mises_au_point: MiseAuPointRow[];
31
+ nombre_contre: string | null;
32
+ nombre_contre_seance: string | null;
33
+ nombre_majorite: string | null;
34
+ nombre_majorite_seance: string | null;
35
+ nombre_pour: string | null;
36
+ nombre_pour_seance: string | null;
37
+ nombre_suffrages: string | null;
38
+ nombre_suffrages_seance: string | null;
39
+ nombre_votants: string | null;
40
+ nombre_votants_seance: string | null;
41
+ note: string | null;
42
+ numero: string;
43
+ session: string;
44
+ signet_dossier: string | null;
45
+ type_lecture: string | null;
46
+ votes: VoteScrutinRow[];
47
+ }
48
+ export declare function findAllScrutins(fromSession?: number): AsyncGenerator<ScrutinResult, void, unknown>;
@@ -1,114 +1,121 @@
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) {
1
+ import { streamUnsafeQuery } from "../databases_postgres";
2
+ function buildFindAllScrutinsQuery(fromSession) {
3
+ const params = [];
4
+ const whereSession = fromSession === undefined ? "" : "where scr.sesann >= $1";
110
5
  if (fromSession !== undefined) {
111
- return findAllScrutinsQuery.where("scr.sesann", ">=", fromSession).stream();
6
+ params.push(String(fromSession));
7
+ }
8
+ return {
9
+ params,
10
+ query: `
11
+ select
12
+ scr.sesann::text as session,
13
+ scr.scrnum::text as numero,
14
+ rtrim(date_seance.lecidt) as lecture_id,
15
+ rtrim(lecture.leccom) as lecture_libelle,
16
+ loi.signet as signet_dossier,
17
+ rtrim(typlec.typleclib) as type_lecture,
18
+ to_char(scr.scrdat, 'YYYY-MM-DD') as date_scrutin,
19
+ to_char(scr.scrdateff, 'YYYY-MM-DD') as date_scrutin_effective,
20
+ replace(scr.scrint, E'\\u0092', '''') as intitule,
21
+ scr.scrbaspag as note,
22
+ scr.scrmaj::text as nombre_majorite,
23
+ scr.scrmajsea::text as nombre_majorite_seance,
24
+ scr.scrvot::text as nombre_votants,
25
+ scr.scrvotsea::text as nombre_votants_seance,
26
+ scr.scrsuf::text as nombre_suffrages,
27
+ scr.scrsufsea::text as nombre_suffrages_seance,
28
+ scr.scrcon::text as nombre_contre,
29
+ scr.scrconsea::text as nombre_contre_seance,
30
+ scr.scrpou::text as nombre_pour,
31
+ scr.scrpousea::text as nombre_pour_seance,
32
+ (
33
+ select coalesce(json_agg(vote_rows order by vote_rows.membership_start desc nulls last), '[]'::json)
34
+ from (
35
+ select
36
+ votsen.senmat as matricule_votant,
37
+ votsen.senmatdel as matricule_delegant,
38
+ posvot.posvotlib as position,
39
+ stavot.stavotlib as statut_votant,
40
+ titsen.titsenlib as titre_votant,
41
+ memgrppol.memgrppolid::text as groupe_politique_id,
42
+ memgrppol.grppolcod as groupe_politique_code,
43
+ memgrppol.memgrppoldatdeb as membership_start
44
+ from senat.dosleg_votsen as votsen
45
+ left join senat.dosleg_titsen as titsen on titsen.titsencod = votsen.titsencod
46
+ left join senat.dosleg_stavot as stavot on stavot.stavotidt = votsen.stavotidt
47
+ left join senat.dosleg_posvot as posvot on posvot.posvotcod = votsen.posvotcod
48
+ left join senat.sens_memgrppol as memgrppol
49
+ on memgrppol.senmat = votsen.senmat
50
+ and memgrppol.memgrppoldatdeb <= scr.scrdat
51
+ and (memgrppol.memgrppoldatfin >= scr.scrdat or memgrppol.memgrppoldatfin is null)
52
+ where votsen.scrnum = scr.scrnum
53
+ and votsen.sesann = scr.sesann
54
+ ) as vote_rows
55
+ ) as votes,
56
+ (
57
+ select coalesce(json_agg(group_rows order by group_rows.groupe_politique_code nulls last), '[]'::json)
58
+ from (
59
+ select
60
+ unique_votes.grppolcod as groupe_politique_code,
61
+ sum(case when unique_votes.posvotlib = 'pour' then 1 else 0 end)::text as nombre_pour,
62
+ sum(case when unique_votes.posvotlib = 'contre' then 1 else 0 end)::text as nombre_contre,
63
+ sum(case when unique_votes.posvotlib = 'abstention' then 1 else 0 end)::text as nombre_abstentions,
64
+ sum(case when unique_votes.posvotlib = 'non-votant' then 1 else 0 end)::text as nombre_non_votants,
65
+ count(unique_votes.senmat)::text as nombre_votants
66
+ from (
67
+ select
68
+ votsen.senmat,
69
+ posvot.posvotlib,
70
+ stavot.stavotlib,
71
+ memgrppol.grppolcod,
72
+ row_number() over (
73
+ partition by votsen.senmat, votsen.scrnum, votsen.sesann
74
+ order by memgrppol.memgrppoldatdeb desc nulls last
75
+ ) as vote_rank
76
+ from senat.dosleg_votsen as votsen
77
+ left join senat.dosleg_posvot as posvot on posvot.posvotcod = votsen.posvotcod
78
+ left join senat.dosleg_stavot as stavot on stavot.stavotidt = votsen.stavotidt
79
+ left join senat.sens_memgrppol as memgrppol
80
+ on memgrppol.senmat = votsen.senmat
81
+ and memgrppol.memgrppoldatdeb <= scr.scrdat
82
+ and (memgrppol.memgrppoldatfin >= scr.scrdat or memgrppol.memgrppoldatfin is null)
83
+ where votsen.scrnum = scr.scrnum
84
+ and votsen.sesann = scr.sesann
85
+ ) as unique_votes
86
+ where unique_votes.vote_rank = 1
87
+ group by unique_votes.grppolcod
88
+ ) as group_rows
89
+ ) as groupes_votants,
90
+ (
91
+ select coalesce(json_agg(correction_rows order by correction_rows.ordre nulls last), '[]'::json)
92
+ from (
93
+ select
94
+ corscr.corscrtxt as texte,
95
+ corscr.corscrord::text as ordre,
96
+ corscr.corscrurl as url
97
+ from senat.dosleg_corscr as corscr
98
+ where corscr.scrnum = scr.scrnum
99
+ ) as correction_rows
100
+ ) as mises_au_point
101
+ from senat.dosleg_scr as scr
102
+ left join senat.dosleg_date_seance as date_seance on scr.code = date_seance.code
103
+ left join senat.dosleg_lecass as lecass on date_seance.lecidt = lecass.lecassidt
104
+ left join senat.dosleg_lecture as lecture on lecture.lecidt = lecass.lecidt
105
+ left join senat.dosleg_loi as loi on loi.loicod = lecture.loicod
106
+ left join senat.dosleg_typlec as typlec on typlec.typleccod = lecture.typleccod
107
+ ${whereSession}
108
+ `,
109
+ };
110
+ }
111
+ export async function* findAllScrutins(fromSession) {
112
+ const { query, params } = buildFindAllScrutinsQuery(fromSession);
113
+ for await (const row of streamUnsafeQuery(query, params)) {
114
+ yield {
115
+ ...row,
116
+ groupes_votants: row.groupes_votants ?? [],
117
+ mises_au_point: row.mises_au_point ?? [],
118
+ votes: row.votes ?? [],
119
+ };
112
120
  }
113
- return findAllScrutinsQuery.stream();
114
121
  }
@@ -140,10 +140,10 @@ function extractAndRemoveLeadingQualite($, $block) {
140
140
  $node.remove();
141
141
  }
142
142
  else if (node.type === "text") {
143
- const t = norm(node.data || "");
143
+ const textNode = node;
144
+ const t = norm(textNode.data || "");
144
145
  if (!t || /^[:.,;–—-]+$/.test(t)) {
145
- ;
146
- node.data = "";
146
+ textNode.data = "";
147
147
  return;
148
148
  }
149
149
  stop = true;