@tricoteuses/senat 2.8.6 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/model/dosleg.d.ts +0 -29
- package/lib/model/questions.d.ts +20 -0
- package/lib/model/questions.js +32 -1
- package/lib/model/sens.d.ts +670 -82
- package/lib/raw_types/dosleg.d.ts +77 -1994
- package/lib/raw_types/questions.d.ts +70 -0
- package/lib/raw_types/sens.d.ts +5424 -1570
- package/lib/raw_types_schemats/ameli.d.ts +12 -2
- package/lib/raw_types_schemats/debats.d.ts +2 -2
- package/lib/raw_types_schemats/dosleg.d.ts +2 -1054
- package/lib/raw_types_schemats/questions.d.ts +4 -2
- package/lib/raw_types_schemats/sens.d.ts +4235 -29
- package/package.json +9 -10
- package/lib/aggregates.d.ts +0 -52
- package/lib/aggregates.js +0 -949
- package/lib/aggregates.mjs +0 -726
- package/lib/aggregates.ts +0 -852
- package/lib/config.mjs +0 -16
- package/lib/config.ts +0 -26
- package/lib/databases.mjs +0 -55
- package/lib/databases.ts +0 -68
- package/lib/datasets.mjs +0 -78
- package/lib/datasets.ts +0 -118
- package/lib/fields.d.ts +0 -10
- package/lib/fields.js +0 -68
- package/lib/fields.mjs +0 -22
- package/lib/fields.ts +0 -29
- package/lib/index.mjs +0 -7
- package/lib/index.ts +0 -64
- package/lib/inserters.d.ts +0 -98
- package/lib/inserters.js +0 -500
- package/lib/inserters.mjs +0 -360
- package/lib/inserters.ts +0 -521
- package/lib/legislatures.json +0 -38
- package/lib/loaders.mjs +0 -97
- package/lib/loaders.ts +0 -173
- package/lib/model/ameli.mjs +0 -57
- package/lib/model/ameli.ts +0 -86
- package/lib/model/debats.mjs +0 -43
- package/lib/model/debats.ts +0 -68
- package/lib/model/dosleg.mjs +0 -163
- package/lib/model/dosleg.ts +0 -204
- package/lib/model/index.mjs +0 -4
- package/lib/model/index.ts +0 -13
- package/lib/model/questions.mjs +0 -76
- package/lib/model/questions.ts +0 -102
- package/lib/model/sens.mjs +0 -339
- package/lib/model/sens.ts +0 -432
- package/lib/model/texte.mjs +0 -156
- package/lib/model/texte.ts +0 -174
- package/lib/raw_types_kysely/ameli.d.ts +0 -915
- package/lib/raw_types_kysely/ameli.js +0 -7
- package/lib/raw_types_kysely/ameli.mjs +0 -5
- package/lib/raw_types_kysely/ameli.ts +0 -951
- package/lib/raw_types_kysely/debats.d.ts +0 -207
- package/lib/raw_types_kysely/debats.js +0 -7
- package/lib/raw_types_kysely/debats.mjs +0 -5
- package/lib/raw_types_kysely/debats.ts +0 -222
- package/lib/raw_types_kysely/dosleg.d.ts +0 -3532
- package/lib/raw_types_kysely/dosleg.js +0 -7
- package/lib/raw_types_kysely/dosleg.mjs +0 -5
- package/lib/raw_types_kysely/dosleg.ts +0 -3621
- package/lib/raw_types_kysely/questions.d.ts +0 -414
- package/lib/raw_types_kysely/questions.js +0 -7
- package/lib/raw_types_kysely/questions.mjs +0 -5
- package/lib/raw_types_kysely/questions.ts +0 -426
- package/lib/raw_types_kysely/sens.d.ts +0 -4394
- package/lib/raw_types_kysely/sens.js +0 -7
- package/lib/raw_types_kysely/sens.mjs +0 -5
- package/lib/raw_types_kysely/sens.ts +0 -4499
- package/lib/raw_types_schemats/ameli.mjs +0 -2
- package/lib/raw_types_schemats/ameli.ts +0 -601
- package/lib/raw_types_schemats/debats.mjs +0 -2
- package/lib/raw_types_schemats/debats.ts +0 -145
- package/lib/raw_types_schemats/dosleg.mjs +0 -2
- package/lib/raw_types_schemats/dosleg.ts +0 -2193
- package/lib/raw_types_schemats/questions.mjs +0 -2
- package/lib/raw_types_schemats/questions.ts +0 -249
- package/lib/raw_types_schemats/sens.mjs +0 -2
- package/lib/raw_types_schemats/sens.ts +0 -2907
- package/lib/scripts/convert_data.mjs +0 -95
- package/lib/scripts/convert_data.ts +0 -119
- package/lib/scripts/datautil.mjs +0 -16
- package/lib/scripts/datautil.ts +0 -19
- package/lib/scripts/images/transparent_150x192.jpg +0 -0
- package/lib/scripts/images/transparent_155x225.jpg +0 -0
- package/lib/scripts/parse_textes.mjs +0 -38
- package/lib/scripts/parse_textes.ts +0 -52
- package/lib/scripts/retrieve_documents.mjs +0 -243
- package/lib/scripts/retrieve_documents.ts +0 -279
- package/lib/scripts/retrieve_open_data.mjs +0 -214
- package/lib/scripts/retrieve_open_data.ts +0 -261
- package/lib/scripts/retrieve_senateurs_photos.mjs +0 -147
- package/lib/scripts/retrieve_senateurs_photos.ts +0 -177
- package/lib/scripts/retrieve_textes.d.ts +0 -1
- package/lib/scripts/retrieve_textes.mjs +0 -165
- package/lib/scripts/retrieve_textes.ts +0 -79
- package/lib/scripts/shared/cli_helpers.ts +0 -36
- package/lib/scripts/shared/util.ts +0 -33
- package/lib/strings.mjs +0 -18
- package/lib/strings.ts +0 -26
- package/lib/types/ameli.mjs +0 -13
- package/lib/types/ameli.ts +0 -21
- package/lib/types/debats.mjs +0 -2
- package/lib/types/debats.ts +0 -6
- package/lib/types/dosleg.mjs +0 -151
- package/lib/types/dosleg.ts +0 -284
- package/lib/types/questions.mjs +0 -1
- package/lib/types/questions.ts +0 -3
- package/lib/types/sens.mjs +0 -1
- package/lib/types/sens.ts +0 -12
- package/lib/types/sessions.mjs +0 -43
- package/lib/types/sessions.ts +0 -42
- package/lib/types/texte.mjs +0 -16
- package/lib/types/texte.ts +0 -66
- package/lib/typings/windows-1252.d.js +0 -2
- package/lib/typings/windows-1252.d.mjs +0 -2
- package/lib/typings/windows-1252.d.ts +0 -11
- package/lib/validators/config.mjs +0 -54
- package/lib/validators/config.ts +0 -79
- package/lib/validators/senat.d.ts +0 -0
- package/lib/validators/senat.js +0 -24
- package/lib/validators/senat.mjs +0 -24
- package/lib/validators/senat.ts +0 -26
package/lib/model/dosleg.ts
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { Expression, InferResult, NotNull, sql } from "kysely"
|
|
2
|
-
import { dbDosleg } from "../databases"
|
|
3
|
-
import { jsonArrayFrom } from "kysely/helpers/postgres"
|
|
4
|
-
|
|
5
|
-
function datesSeances (lectureAssembleeId: Expression<string>) {
|
|
6
|
-
return jsonArrayFrom(
|
|
7
|
-
dbDosleg.selectFrom("date_seance")
|
|
8
|
-
.where("date_seance.lecidt", "=", lectureAssembleeId)
|
|
9
|
-
.select([
|
|
10
|
-
"date_seance.date_s as date",
|
|
11
|
-
]),
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function organismesRapport (rapportId: Expression<string>) {
|
|
16
|
-
return jsonArrayFrom(
|
|
17
|
-
dbDosleg.selectFrom("org")
|
|
18
|
-
.leftJoin("raporg", "raporg.orgcod", "org.orgcod")
|
|
19
|
-
.where("raporg.rapcod", "=", rapportId)
|
|
20
|
-
.select([
|
|
21
|
-
"org.orgnom as libelle",
|
|
22
|
-
]),
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function auteursRapport (rapportId: Expression<string>) {
|
|
27
|
-
return jsonArrayFrom(
|
|
28
|
-
dbDosleg.selectFrom("auteur")
|
|
29
|
-
.leftJoin("ecr", "ecr.autcod", "auteur.autcod")
|
|
30
|
-
.where("ecr.rapcod", "=", rapportId)
|
|
31
|
-
.select([
|
|
32
|
-
"auteur.prenom as prenom",
|
|
33
|
-
"auteur.nomuse as nom_usuel",
|
|
34
|
-
"auteur.autmat as matricule",
|
|
35
|
-
])
|
|
36
|
-
.orderBy("ecr.ecrnumtri", "asc"),
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function rapports (lectureAssembleeId: Expression<string>) {
|
|
41
|
-
return jsonArrayFrom(
|
|
42
|
-
dbDosleg.selectFrom("rap")
|
|
43
|
-
.leftJoin("lecassrap", "lecassrap.rapcod", "rap.rapcod")
|
|
44
|
-
.leftJoin("denrap", "denrap.coddenrap", "rap.coddenrap")
|
|
45
|
-
.where("lecassrap.lecassidt", "=", lectureAssembleeId)
|
|
46
|
-
.select((eb) => [
|
|
47
|
-
"rap.rapnum as numero",
|
|
48
|
-
sql<string>`rtrim(denrap.libdenrap)`.as("type_rapport"),
|
|
49
|
-
eb.case()
|
|
50
|
-
.when("rap.typurl", "=", "I")
|
|
51
|
-
.then(sql<string>`concat('https://www.senat.fr/rap/', rtrim(rap.rapurl))`)
|
|
52
|
-
.else(sql<string>`rtrim(rap.rapurl)`)
|
|
53
|
-
.end()
|
|
54
|
-
.as("url"),
|
|
55
|
-
"rap.date_depot as date_depot",
|
|
56
|
-
auteursRapport(eb.ref("rap.rapcod")).as("auteurs"),
|
|
57
|
-
organismesRapport(eb.ref("rap.rapcod")).as("organismes"),
|
|
58
|
-
]),
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function auteursTextes (texteId: Expression<string>) {
|
|
63
|
-
return jsonArrayFrom(
|
|
64
|
-
dbDosleg.selectFrom("auteur")
|
|
65
|
-
.leftJoin("ecr", "ecr.autcod", "auteur.autcod")
|
|
66
|
-
.where("ecr.texcod", "=", texteId)
|
|
67
|
-
.select([
|
|
68
|
-
"auteur.prenom as prenom",
|
|
69
|
-
"auteur.nomuse as nom_usuel",
|
|
70
|
-
"auteur.autmat as matricule",
|
|
71
|
-
])
|
|
72
|
-
.orderBy("ecr.ecrnumtri", "asc"),
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function textes (lectureAssembleeId: Expression<string>) {
|
|
77
|
-
return jsonArrayFrom(
|
|
78
|
-
dbDosleg.selectFrom("texte")
|
|
79
|
-
.leftJoin("oritxt", "oritxt.oritxtcod", "texte.oritxtcod")
|
|
80
|
-
.leftJoin("typtxt", "typtxt.typtxtcod", "texte.typtxtcod")
|
|
81
|
-
.where("texte.lecassidt", "=", lectureAssembleeId)
|
|
82
|
-
.select((eb) => [
|
|
83
|
-
"texte.texnum as numero",
|
|
84
|
-
eb.case()
|
|
85
|
-
.when("texte.typurl", "=", "I")
|
|
86
|
-
.then(sql<string>`concat('https://www.senat.fr/leg/', rtrim(texte.texurl))`)
|
|
87
|
-
.else(sql<string>`rtrim(texte.texurl)`)
|
|
88
|
-
.end()
|
|
89
|
-
.as("url"),
|
|
90
|
-
sql<string>`rtrim(oritxt.oritxtlib)`.as("origine_texte"),
|
|
91
|
-
sql<string>`rtrim(typtxt.typtxtlib)`.as("type_texte"),
|
|
92
|
-
"texte.txtoritxtdat as date",
|
|
93
|
-
"sesann as session",
|
|
94
|
-
auteursTextes(eb.ref("texte.texcod")).as("auteurs"),
|
|
95
|
-
])
|
|
96
|
-
.orderBy(sql`array_position(array['0','2','1'], oritxt.oriordre)`)
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function lecturesAssemblee (lectureId: Expression<string>) {
|
|
101
|
-
return jsonArrayFrom(
|
|
102
|
-
dbDosleg.selectFrom("lecass")
|
|
103
|
-
.where("lecass.lecidt", "=", lectureId)
|
|
104
|
-
.leftJoin("ass", "ass.codass", "lecass.codass")
|
|
105
|
-
.leftJoin("org", "org.orgcod", "lecass.orgcod")
|
|
106
|
-
.select(({ ref }) => [
|
|
107
|
-
sql<string>`rtrim(ass.libass)`.as("assemblee"),
|
|
108
|
-
"org.orgnom as libelle_organisme",
|
|
109
|
-
textes(ref("lecass.lecassidt")).as("textes"),
|
|
110
|
-
rapports(ref("lecass.lecassidt")).as("rapports"),
|
|
111
|
-
datesSeances(ref("lecass.lecassidt")).as("dates_seances"),
|
|
112
|
-
])
|
|
113
|
-
.orderBy("lecass.ordreass", "asc"),
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function lectures (loiId: Expression<string>) {
|
|
118
|
-
return jsonArrayFrom(
|
|
119
|
-
dbDosleg.selectFrom("lecture")
|
|
120
|
-
.leftJoin("typlec", "typlec.typleccod", "lecture.typleccod")
|
|
121
|
-
.where("lecture.loicod", "=", loiId)
|
|
122
|
-
.select(({ ref }) => [
|
|
123
|
-
sql<string>`rtrim(typlec.typleclib)`.as("type_lecture"),
|
|
124
|
-
sql<string>`rtrim(lecture.leccom)`.as("libelle"),
|
|
125
|
-
lecturesAssemblee(ref("lecture.lecidt")).as("lectures_assemblee"),
|
|
126
|
-
])
|
|
127
|
-
.orderBy("typlec.typlecord", "asc"),
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function themes (loiId: Expression<string>) {
|
|
132
|
-
return jsonArrayFrom(
|
|
133
|
-
dbDosleg.selectFrom("the")
|
|
134
|
-
.leftJoin("loithe", "loithe.thecle", "the.thecle")
|
|
135
|
-
.where("loithe.loicod", "=", loiId)
|
|
136
|
-
.select([
|
|
137
|
-
"the.thelib as libelle",
|
|
138
|
-
]),
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const findAllQuery = dbDosleg
|
|
143
|
-
.selectFrom("loi")
|
|
144
|
-
.leftJoin("typloi", "typloi.typloicod", "loi.typloicod")
|
|
145
|
-
.leftJoin("etaloi", "etaloi.etaloicod", "loi.etaloicod")
|
|
146
|
-
.select(({ ref }) => [
|
|
147
|
-
"loi.signet as signet",
|
|
148
|
-
sql<string>`concat('https://www.senat.fr/dossier-legislatif/', loi.signet, '.html')`.as("url"),
|
|
149
|
-
sql<string>`concat(rtrim(typloi.typloilib), ' ', rtrim(loi.loitit))`.as("titre"),
|
|
150
|
-
sql<string>`rtrim(typloi.typloilib)`.as("type_dossier"),
|
|
151
|
-
sql<string>`rtrim(etaloi.etaloilib)`.as("etat_dossier"),
|
|
152
|
-
"loi.url_an as url_dossier_assemblee_nationale",
|
|
153
|
-
//" as decision_conseil_constitutionnel", // TODO
|
|
154
|
-
//" as date_decision_conseil_constitutionnel", // TODO
|
|
155
|
-
"loi.date_loi as date_promulgation",
|
|
156
|
-
"loi.numero as numero_loi",
|
|
157
|
-
lectures(ref("loi.loicod")).as("lectures"),
|
|
158
|
-
themes(ref("loi.loicod")).as("themes"),
|
|
159
|
-
])
|
|
160
|
-
.$narrowType<{ signet: NotNull }>()
|
|
161
|
-
|
|
162
|
-
export function findAll () {
|
|
163
|
-
return findAllQuery.stream()
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function findSenatTexteUrls (sessions: string[] = []): AsyncIterableIterator<{
|
|
167
|
-
url: string,
|
|
168
|
-
session: string | null | undefined
|
|
169
|
-
}> {
|
|
170
|
-
return dbDosleg
|
|
171
|
-
.selectFrom("texte")
|
|
172
|
-
.where("texurl", "is not", null)
|
|
173
|
-
.where("typurl", "=", "I")
|
|
174
|
-
.$if(sessions.length > 0, (qb) => qb
|
|
175
|
-
.where("sesann", "in", sessions),
|
|
176
|
-
)
|
|
177
|
-
.select([
|
|
178
|
-
sql<string>`rtrim(texurl)`.as("url"),
|
|
179
|
-
"sesann as session",
|
|
180
|
-
])
|
|
181
|
-
.$narrowType<{ url: NotNull }>()
|
|
182
|
-
.stream()
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function findSenatRapportUrls (sessions: string[] = []): AsyncIterableIterator<{
|
|
186
|
-
url: string,
|
|
187
|
-
session: string | null | undefined
|
|
188
|
-
}> {
|
|
189
|
-
return dbDosleg
|
|
190
|
-
.selectFrom("rap")
|
|
191
|
-
.where("rapurl", "is not", null)
|
|
192
|
-
.where("typurl", "=", "I")
|
|
193
|
-
.$if(sessions.length > 0, (qb) => qb
|
|
194
|
-
.where("sesann", "in", sessions),
|
|
195
|
-
)
|
|
196
|
-
.select([
|
|
197
|
-
sql<string>`rtrim(rapurl)`.as("url"),
|
|
198
|
-
"sesann as session",
|
|
199
|
-
])
|
|
200
|
-
.$narrowType<{ url: NotNull }>()
|
|
201
|
-
.stream()
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export type DossierLegislatifResult = InferResult<typeof findAllQuery>[0]
|
package/lib/model/index.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { findAll as findAllLois, } from "./dosleg";
|
|
2
|
-
export { findAll as findAllQuestions, getDbSchema as getQuestionsDbSchema, } from "./questions";
|
|
3
|
-
export { findAll as findAllSens, findAllCirconscriptions, getDbSchema as getSensDbSchema, } from "./sens";
|
|
4
|
-
export { allFollows, Aggregator } from "../aggregates";
|
package/lib/model/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
findAll as findAllLois,
|
|
3
|
-
} from "./dosleg"
|
|
4
|
-
export {
|
|
5
|
-
findAll as findAllQuestions,
|
|
6
|
-
getDbSchema as getQuestionsDbSchema,
|
|
7
|
-
} from "./questions"
|
|
8
|
-
export {
|
|
9
|
-
findAll as findAllSens,
|
|
10
|
-
findAllCirconscriptions,
|
|
11
|
-
getDbSchema as getSensDbSchema,
|
|
12
|
-
} from "./sens"
|
|
13
|
-
export { allFollows, Aggregator } from "../aggregates"
|
package/lib/model/questions.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { sql } from "kysely";
|
|
2
|
-
import { jsonArrayFrom } from "kysely/helpers/postgres";
|
|
3
|
-
import { dbQuestions } from "../databases";
|
|
4
|
-
function reponses(questionId) {
|
|
5
|
-
return jsonArrayFrom(dbQuestions.selectFrom("tam_reponses")
|
|
6
|
-
.where("tam_reponses.idque", "=", questionId)
|
|
7
|
-
.select([
|
|
8
|
-
"tam_reponses.datejorep as date_reponse_JO",
|
|
9
|
-
"tam_reponses.minreplib as ministere_reponse",
|
|
10
|
-
"tam_reponses.txtrep as texte",
|
|
11
|
-
"tam_reponses.txterrrep as texte_erratum",
|
|
12
|
-
])
|
|
13
|
-
.orderBy("tam_reponses.datejorep asc"));
|
|
14
|
-
}
|
|
15
|
-
function themes(questionId) {
|
|
16
|
-
return jsonArrayFrom(dbQuestions.with("question_theme", (db) => db
|
|
17
|
-
.selectFrom("tam_questions")
|
|
18
|
-
.select([
|
|
19
|
-
"id as question_id",
|
|
20
|
-
eb => eb
|
|
21
|
-
.cast(sql `unnest(regexp_matches(tam_questions.themes, '#(\\d+)', 'g'))`, "smallint")
|
|
22
|
-
.as("theme_id"),
|
|
23
|
-
]))
|
|
24
|
-
.selectFrom("the")
|
|
25
|
-
.leftJoin("question_theme", "the.thenouidt", "question_theme.theme_id")
|
|
26
|
-
.where("question_theme.question_id", "=", questionId)
|
|
27
|
-
.select("the.thelib as libelle")
|
|
28
|
-
.orderBy("the.thenouidt asc"));
|
|
29
|
-
}
|
|
30
|
-
const findAllQuery = dbQuestions
|
|
31
|
-
.selectFrom("tam_questions")
|
|
32
|
-
.leftJoin("tam_ministeres", "tam_questions.mindepotid", "tam_ministeres.minid")
|
|
33
|
-
.leftJoin("sortquestion", (join) => join
|
|
34
|
-
.onRef("tam_questions.sorquecod", "=", eb => eb.cast("sortquestion.sorquecod", "bigint")))
|
|
35
|
-
.leftJoin("naturequestion", "tam_questions.natquecod", "naturequestion.natquecod")
|
|
36
|
-
.leftJoin("etatquestion", (join) => join
|
|
37
|
-
.onRef("tam_questions.etaquecod", "=", eb => eb.cast("etatquestion.etaquecod", "bigint")))
|
|
38
|
-
.select([
|
|
39
|
-
"tam_questions.repub as republique",
|
|
40
|
-
"tam_questions.legislature as legislature",
|
|
41
|
-
"sortquestion.sorquelib as sort",
|
|
42
|
-
"tam_questions.natquecod as nature",
|
|
43
|
-
"tam_questions.numero as numero",
|
|
44
|
-
"tam_questions.reference as reference",
|
|
45
|
-
"tam_questions.titre as titre",
|
|
46
|
-
"tam_questions.nom as nom",
|
|
47
|
-
"tam_questions.prenom as prenom",
|
|
48
|
-
"tam_questions.codequalite as civilite",
|
|
49
|
-
"tam_questions.matricule as matricule",
|
|
50
|
-
"tam_questions.circonscription as circonscription",
|
|
51
|
-
"tam_questions.groupe as groupe",
|
|
52
|
-
"tam_questions.ratgrp as type_appartenance",
|
|
53
|
-
"tam_questions.datejodepot as date_publication_JO",
|
|
54
|
-
"tam_questions.mindepotlib as ministere_depot",
|
|
55
|
-
"tam_ministeres.datedebut as ministere_depot_date_debut",
|
|
56
|
-
"tam_questions.datejotran as date_transmission",
|
|
57
|
-
"tam_questions.mintranlib as ministere_transmission",
|
|
58
|
-
"tam_questions.datejorep1 as date_reponse_JO",
|
|
59
|
-
"tam_questions.minreplib1 as ministere_reponse",
|
|
60
|
-
"tam_questions.datecloture as date_cloture",
|
|
61
|
-
"tam_questions.refquerappelee as reference_question_rappelee",
|
|
62
|
-
//"tam_questions.url as url", // TODO ?
|
|
63
|
-
"tam_questions.txtque as texte",
|
|
64
|
-
"tam_questions.txtque as texte_erratum",
|
|
65
|
-
"tam_questions.rubrique as rubrique",
|
|
66
|
-
])
|
|
67
|
-
.select(({ ref }) => [
|
|
68
|
-
themes(ref("tam_questions.id")).as("themes"),
|
|
69
|
-
reponses(ref("tam_questions.id")).as("reponses"),
|
|
70
|
-
]);
|
|
71
|
-
export function findAll() {
|
|
72
|
-
return findAllQuery.stream();
|
|
73
|
-
}
|
|
74
|
-
export function getDbSchema() {
|
|
75
|
-
return dbQuestions.introspection.getTables();
|
|
76
|
-
}
|
package/lib/model/questions.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Expression, InferResult, sql } from "kysely"
|
|
2
|
-
import { jsonArrayFrom } from "kysely/helpers/postgres"
|
|
3
|
-
|
|
4
|
-
import { dbQuestions } from "../databases"
|
|
5
|
-
|
|
6
|
-
function reponses (questionId: Expression<string>) {
|
|
7
|
-
return jsonArrayFrom(
|
|
8
|
-
dbQuestions.selectFrom("tam_reponses")
|
|
9
|
-
.where("tam_reponses.idque", "=", questionId)
|
|
10
|
-
.select([
|
|
11
|
-
"tam_reponses.datejorep as date_reponse_JO",
|
|
12
|
-
"tam_reponses.minreplib as ministere_reponse",
|
|
13
|
-
"tam_reponses.txtrep as texte",
|
|
14
|
-
"tam_reponses.txterrrep as texte_erratum",
|
|
15
|
-
])
|
|
16
|
-
.orderBy("tam_reponses.datejorep asc"),
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function themes (questionId: Expression<string>) {
|
|
21
|
-
return jsonArrayFrom(
|
|
22
|
-
dbQuestions.with("question_theme", (db) => db
|
|
23
|
-
.selectFrom("tam_questions")
|
|
24
|
-
.select([
|
|
25
|
-
"id as question_id",
|
|
26
|
-
eb => eb
|
|
27
|
-
.cast<number>(
|
|
28
|
-
sql`unnest(regexp_matches(tam_questions.themes, '#(\\d+)', 'g'))`,
|
|
29
|
-
"smallint"
|
|
30
|
-
)
|
|
31
|
-
.as("theme_id"),
|
|
32
|
-
]),
|
|
33
|
-
)
|
|
34
|
-
.selectFrom("the")
|
|
35
|
-
.leftJoin("question_theme", "the.thenouidt", "question_theme.theme_id")
|
|
36
|
-
.where("question_theme.question_id", "=", questionId)
|
|
37
|
-
.select("the.thelib as libelle")
|
|
38
|
-
.orderBy("the.thenouidt asc"),
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const findAllQuery = dbQuestions
|
|
43
|
-
.selectFrom("tam_questions")
|
|
44
|
-
.leftJoin("tam_ministeres", "tam_questions.mindepotid", "tam_ministeres.minid")
|
|
45
|
-
.leftJoin("sortquestion", (join) => join
|
|
46
|
-
.onRef(
|
|
47
|
-
"tam_questions.sorquecod",
|
|
48
|
-
"=",
|
|
49
|
-
eb => eb.cast<number>("sortquestion.sorquecod", "bigint"),
|
|
50
|
-
),
|
|
51
|
-
)
|
|
52
|
-
.leftJoin("naturequestion", "tam_questions.natquecod", "naturequestion.natquecod")
|
|
53
|
-
.leftJoin("etatquestion", (join) => join
|
|
54
|
-
.onRef(
|
|
55
|
-
"tam_questions.etaquecod",
|
|
56
|
-
"=",
|
|
57
|
-
eb => eb.cast<number>("etatquestion.etaquecod", "bigint"),
|
|
58
|
-
),
|
|
59
|
-
)
|
|
60
|
-
.select([
|
|
61
|
-
"tam_questions.repub as republique",
|
|
62
|
-
"tam_questions.legislature as legislature",
|
|
63
|
-
"sortquestion.sorquelib as sort",
|
|
64
|
-
"tam_questions.natquecod as nature",
|
|
65
|
-
"tam_questions.numero as numero",
|
|
66
|
-
"tam_questions.reference as reference",
|
|
67
|
-
"tam_questions.titre as titre",
|
|
68
|
-
"tam_questions.nom as nom",
|
|
69
|
-
"tam_questions.prenom as prenom",
|
|
70
|
-
"tam_questions.codequalite as civilite",
|
|
71
|
-
"tam_questions.matricule as matricule",
|
|
72
|
-
"tam_questions.circonscription as circonscription",
|
|
73
|
-
"tam_questions.groupe as groupe",
|
|
74
|
-
"tam_questions.ratgrp as type_appartenance",
|
|
75
|
-
"tam_questions.datejodepot as date_publication_JO",
|
|
76
|
-
"tam_questions.mindepotlib as ministere_depot",
|
|
77
|
-
"tam_ministeres.datedebut as ministere_depot_date_debut",
|
|
78
|
-
"tam_questions.datejotran as date_transmission",
|
|
79
|
-
"tam_questions.mintranlib as ministere_transmission",
|
|
80
|
-
"tam_questions.datejorep1 as date_reponse_JO",
|
|
81
|
-
"tam_questions.minreplib1 as ministere_reponse",
|
|
82
|
-
"tam_questions.datecloture as date_cloture",
|
|
83
|
-
"tam_questions.refquerappelee as reference_question_rappelee",
|
|
84
|
-
//"tam_questions.url as url", // TODO ?
|
|
85
|
-
"tam_questions.txtque as texte",
|
|
86
|
-
"tam_questions.txtque as texte_erratum",
|
|
87
|
-
"tam_questions.rubrique as rubrique",
|
|
88
|
-
])
|
|
89
|
-
.select(({ ref }) => [
|
|
90
|
-
themes(ref("tam_questions.id")).as("themes"),
|
|
91
|
-
reponses(ref("tam_questions.id")).as("reponses"),
|
|
92
|
-
])
|
|
93
|
-
|
|
94
|
-
export type QuestionResult = InferResult<typeof findAllQuery>[0]
|
|
95
|
-
|
|
96
|
-
export function findAll () {
|
|
97
|
-
return findAllQuery.stream()
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function getDbSchema() {
|
|
101
|
-
return dbQuestions.introspection.getTables()
|
|
102
|
-
}
|