@tricoteuses/senat 2.19.7 → 2.19.8
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.
|
@@ -128,9 +128,7 @@ async function main() {
|
|
|
128
128
|
const sessions = getSessionsFromStart(options["fromSession"]);
|
|
129
129
|
console.time("agenda processing time");
|
|
130
130
|
await retrieveAgendas(dataDir, sessions);
|
|
131
|
-
|
|
132
|
-
console.timeEnd("agenda processing time");
|
|
133
|
-
}
|
|
131
|
+
console.timeEnd("agenda processing time");
|
|
134
132
|
}
|
|
135
133
|
main()
|
|
136
134
|
.then(() => process.exit(0))
|
|
@@ -356,9 +356,7 @@ async function main() {
|
|
|
356
356
|
assert(dataDir, "Missing argument: data directory");
|
|
357
357
|
console.time("CRI processing time");
|
|
358
358
|
await retrieveCommissionCRs(options);
|
|
359
|
-
|
|
360
|
-
console.timeEnd("CRI processing time");
|
|
361
|
-
}
|
|
359
|
+
console.timeEnd("CRI processing time");
|
|
362
360
|
}
|
|
363
361
|
main()
|
|
364
362
|
.then(() => process.exit(0))
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import commandLineArgs from "command-line-args";
|
|
8
|
-
import fs from "fs-extra";
|
|
8
|
+
import fs, { ensureDirSync } from "fs-extra";
|
|
9
9
|
import path from "path";
|
|
10
10
|
import StreamZip from "node-stream-zip";
|
|
11
11
|
import * as cheerio from "cheerio";
|
|
@@ -14,7 +14,7 @@ import { commonOptions } from "./shared/cli_helpers";
|
|
|
14
14
|
import { deriveTitreObjetFromSommaire, parseCompteRenduSlotFromFile, parseYYYYMMDD, sessionStartYearFromDate, } from "../model/seance";
|
|
15
15
|
import { makeGroupUid } from "../utils/reunion_grouping";
|
|
16
16
|
import { getSessionsFromStart } from "../types/sessions";
|
|
17
|
-
import {
|
|
17
|
+
import { fetchWithRetry } from "./shared/util";
|
|
18
18
|
import { computeIntervalsBySlot } from "../utils/cr_spliting";
|
|
19
19
|
const optionsDefinitions = [
|
|
20
20
|
...commonOptions,
|
|
@@ -115,7 +115,7 @@ async function extractAndDistributeXmlBySession(zipPath, originalRoot) {
|
|
|
115
115
|
}
|
|
116
116
|
export async function retrieveCriXmlDump(dataDir, options = {}) {
|
|
117
117
|
const root = path.join(dataDir, COMPTES_RENDUS_FOLDER);
|
|
118
|
-
|
|
118
|
+
ensureDirSync(root);
|
|
119
119
|
const originalRoot = path.join(root, DATA_ORIGINAL_FOLDER);
|
|
120
120
|
fs.ensureDirSync(originalRoot);
|
|
121
121
|
const transformedRoot = path.join(root, DATA_TRANSFORMED_FOLDER);
|
|
@@ -153,11 +153,22 @@ export async function retrieveCriXmlDump(dataDir, options = {}) {
|
|
|
153
153
|
}
|
|
154
154
|
const xmlFiles = (await fs.readdir(originalSessionDir)).filter((f) => /^d\d{8}\.xml$/i.test(f)).sort();
|
|
155
155
|
const transformedSessionDir = path.join(transformedRoot, String(session));
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
await fs.ensureDir(transformedSessionDir);
|
|
157
|
+
const now = Date.now();
|
|
158
158
|
for (const f of xmlFiles) {
|
|
159
159
|
const yyyymmdd = f.slice(1, 9);
|
|
160
160
|
const xmlPath = path.join(originalSessionDir, f);
|
|
161
|
+
if (options["only-recent"]) {
|
|
162
|
+
const cutoff = now - options["only-recent"] * 24 * 3600 * 1000;
|
|
163
|
+
const seanceTs = Date.parse(yyyymmdd.slice(0, 4) + "-" + yyyymmdd.slice(4, 6) + "-" + yyyymmdd.slice(6, 8));
|
|
164
|
+
if (seanceTs < cutoff) {
|
|
165
|
+
// Check if some file exists sarting with CRSSN{yyyymmdd} in transformed dir
|
|
166
|
+
const someFile = (await fs.readdir(transformedSessionDir)).find((fn) => fn.startsWith(`CRSSN${yyyymmdd}`));
|
|
167
|
+
if (someFile) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
161
172
|
// 1) Deduce slot(s) from agenda if it exsits
|
|
162
173
|
const agendaInfo = loadAgendaSPSlotsForDate(dataDir, yyyymmdd, session);
|
|
163
174
|
const firstSlotOfDay = pickFirstSlotOfDay(agendaInfo?.slots ?? []);
|
|
@@ -209,9 +220,7 @@ async function main() {
|
|
|
209
220
|
assert(dataDir, "Missing argument: data directory");
|
|
210
221
|
console.time("CRI processing time");
|
|
211
222
|
await retrieveCriXmlDump(dataDir, options);
|
|
212
|
-
|
|
213
|
-
console.timeEnd("CRI processing time");
|
|
214
|
-
}
|
|
223
|
+
console.timeEnd("CRI processing time");
|
|
215
224
|
}
|
|
216
225
|
main()
|
|
217
226
|
.then(() => process.exit(0))
|