@tricoteuses/senat 3.1.18 → 3.1.19
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/src/config.d.ts +0 -22
- package/lib/src/config.js +7 -17
- package/lib/src/conversion_textes.js +1 -5
- package/lib/src/databases.d.ts +2 -0
- package/lib/src/databases.js +26 -0
- package/lib/src/datasets.d.ts +0 -4
- package/lib/src/datasets.js +2 -16
- package/lib/src/git.d.ts +0 -1
- package/lib/src/git.js +11 -45
- package/lib/src/loaders.d.ts +12 -12
- package/lib/src/loaders.js +8 -14
- package/lib/src/model/agenda.d.ts +1 -1
- package/lib/src/model/agenda.js +3 -3
- package/lib/src/model/ameli.d.ts +52 -64
- package/lib/src/model/ameli.js +145 -147
- package/lib/src/model/commission.d.ts +4 -5
- package/lib/src/model/commission.js +6 -6
- package/lib/src/model/debats.d.ts +66 -38
- package/lib/src/model/debats.js +93 -110
- package/lib/src/model/documents.d.ts +12 -32
- package/lib/src/model/documents.js +130 -171
- package/lib/src/model/dosleg.d.ts +5 -142
- package/lib/src/model/dosleg.js +156 -298
- package/lib/src/model/index.d.ts +7 -7
- package/lib/src/model/index.js +7 -7
- package/lib/src/model/questions.d.ts +45 -54
- package/lib/src/model/questions.js +87 -89
- package/lib/src/model/scrutins.d.ts +13 -48
- package/lib/src/model/scrutins.js +111 -118
- package/lib/src/model/seance.d.ts +1 -1
- package/lib/src/model/seance.js +7 -7
- package/lib/src/model/sens.d.ts +179 -109
- package/lib/src/model/sens.js +484 -384
- package/lib/src/model/util.d.ts +8 -0
- package/lib/src/model/util.js +23 -0
- package/lib/src/raw_types/ameli.d.ts +800 -1648
- package/lib/src/raw_types/ameli.js +5 -1074
- package/lib/src/raw_types/debats.d.ts +180 -353
- package/lib/src/raw_types/debats.js +5 -266
- package/lib/src/raw_types/dosleg.d.ts +1523 -2858
- package/lib/src/raw_types/dosleg.js +5 -2005
- package/lib/src/raw_types/questions.d.ts +395 -671
- package/lib/src/raw_types/questions.js +5 -493
- package/lib/src/raw_types/senat.d.ts +11372 -0
- package/lib/src/raw_types/senat.js +5 -0
- package/lib/src/raw_types/sens.d.ts +8148 -7743
- package/lib/src/raw_types/sens.js +5 -4691
- package/lib/src/raw_types_schemats/ameli.d.ts +2 -4
- package/lib/src/raw_types_schemats/debats.d.ts +2 -2
- package/lib/src/raw_types_schemats/dosleg.d.ts +2 -2
- package/lib/src/raw_types_schemats/questions.d.ts +2 -2
- package/lib/src/raw_types_schemats/sens.d.ts +4235 -29
- package/lib/src/scripts/test_iter_load.d.ts +1 -0
- package/lib/src/scripts/test_iter_load.js +12 -0
- package/lib/src/types/ameli.d.ts +4 -4
- package/lib/src/types/dosleg.d.ts +39 -39
- package/lib/src/types/questions.d.ts +2 -2
- package/lib/src/types/sens.d.ts +2 -0
- package/lib/src/types/texte.d.ts +2 -2
- package/lib/src/utils/reunion_odj_building.js +27 -11
- package/package.json +1 -1
- package/lib/src/databases_postgres.d.ts +0 -4
- package/lib/src/databases_postgres.js +0 -23
- package/lib/src/scripts/debug_dosleg_query.d.ts +0 -6
- package/lib/src/scripts/debug_dosleg_query.js +0 -50
|
@@ -1,54 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
date_cloture: string
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
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,91 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
};
|
|
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"));
|
|
81
20
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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();
|
|
91
89
|
}
|
|
@@ -1,48 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
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,121 +1,114 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
};
|
|
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
|
+
]));
|
|
110
67
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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();
|
|
120
112
|
}
|
|
113
|
+
return findAllScrutinsQuery.stream();
|
|
121
114
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CompteRendu } from "../types/compte_rendu
|
|
1
|
+
import { CompteRendu } from "../types/compte_rendu";
|
|
2
2
|
export declare function parseCompteRenduIntervalFromFile(xmlFilePath: string, startIndex: number, endIndex: number, agendaEventId: string): Promise<CompteRendu | null>;
|
|
3
3
|
export declare function sessionStartYearFromDate(d: Date): number;
|
package/lib/src/model/seance.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import * as cheerio from "cheerio";
|
|
3
|
-
import { toCRDate } from "./util
|
|
4
|
-
import { makeReunionUid } from "../utils/reunion_parsing
|
|
5
|
-
import { yyyymmddFromPath } from "../utils/date
|
|
6
|
-
import { decodeHtmlEntities, dedupeSpeaker, fixApostrophes, norm } from "../utils/string_cleaning
|
|
3
|
+
import { toCRDate } from "./util";
|
|
4
|
+
import { makeReunionUid } from "../utils/reunion_parsing";
|
|
5
|
+
import { yyyymmddFromPath } from "../utils/date";
|
|
6
|
+
import { decodeHtmlEntities, dedupeSpeaker, fixApostrophes, norm } from "../utils/string_cleaning";
|
|
7
7
|
export async function parseCompteRenduIntervalFromFile(xmlFilePath, startIndex, endIndex, agendaEventId) {
|
|
8
8
|
try {
|
|
9
9
|
const raw = fs.readFileSync(xmlFilePath, "utf8");
|
|
@@ -140,10 +140,10 @@ function extractAndRemoveLeadingQualite($, $block) {
|
|
|
140
140
|
$node.remove();
|
|
141
141
|
}
|
|
142
142
|
else if (node.type === "text") {
|
|
143
|
-
const
|
|
144
|
-
const t = norm(textNode.data || "");
|
|
143
|
+
const t = norm(node.data || "");
|
|
145
144
|
if (!t || /^[:.,;–—-]+$/.test(t)) {
|
|
146
|
-
|
|
145
|
+
;
|
|
146
|
+
node.data = "";
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
stop = true;
|