text-to-map 1.1.6 → 1.1.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { disconnectKnex, getKnexDb } from "../db/db";
11
+ function main() {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ const knex = getKnexDb();
14
+ yield knex.schema.alterTable("school_founder", (table) => {
15
+ table.unique(["school_izo", "founder_id"]);
16
+ });
17
+ yield disconnectKnex();
18
+ });
19
+ }
20
+ main();
@@ -36,6 +36,7 @@ function main() {
36
36
  };
37
37
  console.time("downloadAndImportAllLatestAddressPoints");
38
38
  const { municipality } = yield getNewMunicipality("Česká Lípa");
39
+ console.log(municipality.founder.schools[0].locations);
39
40
  const addressPoints = yield parseOrdinanceToAddressPoints(lines, {
40
41
  // currentMunicipality: municipality,
41
42
  }, reportErrors, reportWarnings);
@@ -130,10 +130,10 @@ export const getAddressPointById = (addressPointId) => __awaiter(void 0, void 0,
130
130
  const knex = getKnexDb();
131
131
  const row = yield knex.raw(`${addressPointSelect}
132
132
  WHERE a.id = ?`, [addressPointId]);
133
- if (!row) {
133
+ if (row.length === 0) {
134
134
  return null;
135
135
  }
136
- return rowToAddressPoint(row);
136
+ return rowToAddressPoint(row[0]);
137
137
  });
138
138
  let lastFounder = null;
139
139
  let allStreets = [];
package/dist/db/db.d.ts CHANGED
@@ -21,7 +21,7 @@ export declare const nonEmptyOrNull: (value: string) => string | null;
21
21
  * Efficiently insert multiple rows. If preventDuplicatesByFirstColumn is true, the first
22
22
  * column should be unique (PK or UNIQUE).
23
23
  */
24
- export declare const insertMultipleRows: (rows: string[][], table: string, columnNames: string[], preventDuplicates?: boolean, keyColumns?: string[]) => Promise<number>;
24
+ export declare const insertMultipleRows: (rows: string[][], table: string, columnNames: string[], preventDuplicates?: boolean) => Promise<number>;
25
25
  /**
26
26
  * Insert a single row and return the autoincremented ID.
27
27
  */
package/dist/db/db.js CHANGED
@@ -115,17 +115,12 @@ export const nonEmptyOrNull = (value) => {
115
115
  * Efficiently insert multiple rows. If preventDuplicatesByFirstColumn is true, the first
116
116
  * column should be unique (PK or UNIQUE).
117
117
  */
118
- export const insertMultipleRows = (rows, table, columnNames, preventDuplicates = true, keyColumns = []) => __awaiter(void 0, void 0, void 0, function* () {
118
+ export const insertMultipleRows = (rows, table, columnNames, preventDuplicates = true) => __awaiter(void 0, void 0, void 0, function* () {
119
119
  if (rows.length === 0) {
120
120
  return 0;
121
121
  }
122
122
  const insertPlaceholders = generate2DPlaceholders(columnNames.length, rows.length);
123
- if (preventDuplicates && keyColumns.length === 0) {
124
- keyColumns = [columnNames[0]];
125
- }
126
- const onConfict = preventDuplicates
127
- ? `ON CONFLICT (${keyColumns.join(", ")}) DO NOTHING`
128
- : "";
123
+ const onConfict = preventDuplicates ? `ON CONFLICT DO NOTHING` : "";
129
124
  yield getKnexDb().raw(`INSERT INTO ${table} (${columnNames.join(",")}) VALUES ${insertPlaceholders} ${onConfict}`, rows.flat());
130
125
  return rows.length;
131
126
  });
@@ -86,7 +86,7 @@ export const insertFounders = (founders) => __awaiter(void 0, void 0, void 0, fu
86
86
  schoolFounderConnectionData.push([school.izo, founderId]);
87
87
  });
88
88
  }
89
- const insertedConnections = yield insertMultipleRows(schoolFounderConnectionData, "school_founder", ["school_izo", "founder_id"], true, ["school_izo", "founder_id"]);
89
+ const insertedConnections = yield insertMultipleRows(schoolFounderConnectionData, "school_founder", ["school_izo", "founder_id"], true);
90
90
  return insertedFounders + insertedConnections;
91
91
  });
92
92
  const getCityOfSchool = (izo) => __awaiter(void 0, void 0, void 0, function* () {
@@ -38,7 +38,7 @@ export const insertSchools = (schools) => __awaiter(void 0, void 0, void 0, func
38
38
  // plus filter out duplicate locations (same address id + izo)
39
39
  for (const location of locations) {
40
40
  try {
41
- insertedLocations += yield insertMultipleRows([location], "school_location", ["school_izo", "address_point_id"], true, ["school_izo", "address_point_id"]);
41
+ insertedLocations += yield insertMultipleRows([location], "school_location", ["school_izo", "address_point_id"], true);
42
42
  }
43
43
  catch (error) {
44
44
  console.log(`Cannot add location with RUIAN code ${location[1]} (school IZO = ${location[0]}): code does not exist.`);
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "name": "text-to-map",
55
55
  "description": "Text To Map usiluje o lepší, strojově zpracovatelné využití částí vyhlášek s výčtem ulic a dalších lokací. Jde o rozšiřitelnou sadu konceptů a nástrojů, které zajistí hladký převod výčtu ulic a jejich rozsahů v lidsky srozumitelném jazyce do strojově zpracovatelného, uchopitelného formátu.",
56
- "version": "1.1.6",
56
+ "version": "1.1.8",
57
57
  "main": "dist/index.js",
58
58
  "types": "dist/index.d.ts",
59
59
  "files": [