@tricoteuses/senat 2.19.3 → 2.19.5
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
CHANGED
|
@@ -25,9 +25,6 @@ npm install
|
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
docker run --name local-postgres -d -p 5432:5432 -e POSTGRES_PASSWORD=$YOUR_CUSTOM_DB_PASSWORD postgres
|
|
28
|
-
# Default Postgres user is postgres
|
|
29
|
-
# But scripts require an "opendata" role
|
|
30
|
-
docker exec -it local-postgres psql -U postgres -c "CREATE ROLE opendata;"
|
|
31
28
|
```
|
|
32
29
|
|
|
33
30
|
## Download data
|
|
@@ -2,7 +2,6 @@ import assert from "assert";
|
|
|
2
2
|
import { execSync } from "child_process";
|
|
3
3
|
import commandLineArgs from "command-line-args";
|
|
4
4
|
import fs from "fs-extra";
|
|
5
|
-
// import fetch from "node-fetch"
|
|
6
5
|
import path from "path";
|
|
7
6
|
import StreamZip from "node-stream-zip";
|
|
8
7
|
import readline from "readline";
|
|
@@ -79,7 +78,11 @@ async function copyToSenat(dataset, dataDir, options) {
|
|
|
79
78
|
// Write the header and then stream the rest of the SQL file
|
|
80
79
|
const schemaSqlWriter = fs.createWriteStream(schemaDumpFile, { encoding: "utf8" });
|
|
81
80
|
// Add CREATE SCHEMA statement at the top
|
|
81
|
+
schemaSqlWriter.write(`DROP SCHEMA IF EXISTS ${dataset.database} CASCADE;\n`);
|
|
82
82
|
schemaSqlWriter.write(`CREATE SCHEMA IF NOT EXISTS ${dataset.database};\n`);
|
|
83
|
+
schemaSqlWriter.write(`GRANT USAGE ON SCHEMA ${dataset.database} TO ${config.db.user};\n`);
|
|
84
|
+
schemaSqlWriter.write(`GRANT SELECT ON ALL TABLES IN SCHEMA ${dataset.database} TO ${config.db.user};\n`);
|
|
85
|
+
schemaSqlWriter.write(`ALTER DEFAULT PRIVILEGES IN SCHEMA ${dataset.database} GRANT SELECT ON TABLES TO ${config.db.user};\n`);
|
|
83
86
|
const lineReader = readline.createInterface({
|
|
84
87
|
input: fs.createReadStream(sqlFilePath, { encoding: "utf8" }),
|
|
85
88
|
crlfDelay: Infinity,
|
|
@@ -270,12 +273,13 @@ async function retrieveOpenData() {
|
|
|
270
273
|
process.env["PGUSER"] &&
|
|
271
274
|
process.env["PGPASSWORD"], "Missing database configuration: environment variables PGHOST, PGPORT, PGUSER and PGPASSWORD or TRICOTEUSES_SENAT_DB_* in .env file");
|
|
272
275
|
console.time("data extraction time");
|
|
273
|
-
|
|
276
|
+
// Create role 'opendata' if it does not exist
|
|
277
|
+
execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -c "CREATE ROLE opendata" || true`, {
|
|
274
278
|
cwd: dataDir,
|
|
275
279
|
env: process.env,
|
|
276
280
|
encoding: "utf-8",
|
|
277
281
|
});
|
|
278
|
-
execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -c "CREATE DATABASE senat WITH OWNER opendata"`, {
|
|
282
|
+
execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -c "CREATE DATABASE senat WITH OWNER opendata" || true`, {
|
|
279
283
|
cwd: dataDir,
|
|
280
284
|
env: process.env,
|
|
281
285
|
encoding: "utf-8",
|
|
@@ -451,7 +451,7 @@ async function processGroupedReunion(agenda, session, dataDir) {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
else {
|
|
454
|
-
console.warn(`[warn] The video url could not be built
|
|
454
|
+
console.warn(`[warn] The video url could not be built for reunion `, reunionUid);
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
async function processAll(dataDir, sessions) {
|