@golemio/pid 2.7.12-dev.937273478 → 2.7.12-dev.938565701

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,53 @@
1
+ 'use strict';
2
+
3
+ var dbm;
4
+ var type;
5
+ var seed;
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+ var Promise;
9
+
10
+ /**
11
+ * We receive the dbmigrate dependency from dbmigrate initially.
12
+ * This enables us to not have to rely on NODE_PATH.
13
+ */
14
+ exports.setup = function(options, seedLink) {
15
+ dbm = options.dbmigrate;
16
+ type = dbm.dataType;
17
+ seed = seedLink;
18
+ Promise = options.Promise;
19
+ };
20
+
21
+ exports.up = function(db) {
22
+ var filePath = path.join(__dirname, 'sqls', '20230720075810-preset-column-positions-up.sql');
23
+ return new Promise( function( resolve, reject ) {
24
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25
+ if (err) return reject(err);
26
+ console.log('received data: ' + data);
27
+
28
+ resolve(data);
29
+ });
30
+ })
31
+ .then(function(data) {
32
+ return db.runSql(data);
33
+ });
34
+ };
35
+
36
+ exports.down = function(db) {
37
+ var filePath = path.join(__dirname, 'sqls', '20230720075810-preset-column-positions-down.sql');
38
+ return new Promise( function( resolve, reject ) {
39
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40
+ if (err) return reject(err);
41
+ console.log('received data: ' + data);
42
+
43
+ resolve(data);
44
+ });
45
+ })
46
+ .then(function(data) {
47
+ return db.runSql(data);
48
+ });
49
+ };
50
+
51
+ exports._meta = {
52
+ "version": 1
53
+ };
@@ -0,0 +1,62 @@
1
+ DROP VIEW IF EXISTS analytic.v_ropid_departure_boards;
2
+
3
+
4
+ alter table ropid_departures_presets rename to ropid_departures_presets_old;
5
+ CREATE TABLE ropid_departures_presets (
6
+ id integer DEFAULT nextval('ropid_departures_presets_id_seq'::regclass) NOT NULL,
7
+ route_name character varying(100) NOT NULL,
8
+ api_version smallint NOT NULL,
9
+ route character varying(100) NOT NULL,
10
+ url_query_params character varying(400),
11
+ note character varying(1000) NOT NULL,
12
+
13
+ create_batch_id bigint,
14
+ created_at timestamp with time zone,
15
+ created_by character varying(150),
16
+ update_batch_id bigint,
17
+ updated_at timestamp with time zone,
18
+ updated_by character varying(150),
19
+
20
+ is_testing boolean not null default false,
21
+
22
+ CONSTRAINT ropid_departures_presets_pkey PRIMARY KEY (id)
23
+ );
24
+
25
+ create unique index ropid_departures_presets_unique_idx on ropid_departures_presets (route_name);
26
+ insert into ropid_departures_presets (route_name, api_version, route, url_query_params, note, create_batch_id, created_at, created_by, update_batch_id, updated_at, updated_by, is_testing)
27
+ select route_name, api_version, route, url_query_params, note, create_batch_id, created_at, created_by, update_batch_id, updated_at, updated_by, is_testing
28
+ from ropid_departures_presets_old;
29
+
30
+ drop table ropid_departures_presets_old;
31
+
32
+
33
+ CREATE OR REPLACE VIEW analytic.v_ropid_departure_boards
34
+ AS SELECT final.lon,
35
+ final.lat,
36
+ final.route_name,
37
+ final.note,
38
+ final.stop_correct,
39
+ count(1) OVER (PARTITION BY (split_part(final.stop_correct, '/'::text, 1))) AS n_ceduli,
40
+ final.alt_idos_name
41
+ FROM ( SELECT stops.lon,
42
+ stops.lat,
43
+ tab.route_name,
44
+ tab.note,
45
+ tab.stop_correct,
46
+ stops.alt_idos_name,
47
+ row_number() OVER (PARTITION BY tab.note) AS n_duplicit
48
+ FROM ( SELECT rdp.route_name,
49
+ rdp.note,
50
+ CASE
51
+ WHEN rdp.url_query_params::text ~~ '%aswIds%'::text THEN replace("substring"(rdp.url_query_params::text, 'aswIds[^=]*?=(.+?(?=&|$))'::text), '_'::text, '/'::text)
52
+ WHEN rdp.url_query_params::text ~~ '%cisIds%'::text THEN "substring"(rdp.url_query_params::text, 'cisIds[^=]*?=(.+?(?=&|$))'::text)
53
+ ELSE NULL::text
54
+ END AS stop_correct
55
+ FROM ropid_departures_presets rdp) tab
56
+ LEFT JOIN ropidgtfs_cis_stops stops ON
57
+ CASE
58
+ WHEN tab.stop_correct ~~ '%/%'::text THEN tab.stop_correct = stops.id::text
59
+ ELSE tab.stop_correct = split_part(stops.id::text, '/'::text, 1)
60
+ END OR tab.stop_correct = stops.cis::text) final
61
+ WHERE final.n_duplicit = 1
62
+ ORDER BY final.stop_correct;
@@ -0,0 +1,61 @@
1
+ DROP VIEW IF EXISTS analytic.v_ropid_departure_boards;
2
+
3
+
4
+ alter table ropid_departures_presets rename to ropid_departures_presets_old;
5
+ CREATE TABLE ropid_departures_presets (
6
+ id integer DEFAULT nextval('ropid_departures_presets_id_seq'::regclass) NOT NULL,
7
+ route_name character varying(100) NOT NULL,
8
+ api_version smallint NOT NULL,
9
+ route character varying(100) NOT NULL,
10
+ url_query_params character varying(400),
11
+ note character varying(1000) NOT NULL,
12
+ is_testing boolean not null default false,
13
+
14
+ create_batch_id bigint,
15
+ created_at timestamp with time zone,
16
+ created_by character varying(150),
17
+ update_batch_id bigint,
18
+ updated_at timestamp with time zone,
19
+ updated_by character varying(150),
20
+
21
+ CONSTRAINT ropid_departures_presets_new_pkey PRIMARY KEY (id)
22
+ );
23
+
24
+ create unique index ropid_departures_presets_new_unique_idx on ropid_departures_presets (route_name);
25
+ insert into ropid_departures_presets (route_name, api_version, route, url_query_params, note, is_testing, create_batch_id, created_at, created_by, update_batch_id, updated_at, updated_by)
26
+ select route_name, api_version, route, url_query_params, note, is_testing, create_batch_id, created_at, created_by, update_batch_id, updated_at, updated_by
27
+ from ropid_departures_presets_old;
28
+
29
+ drop table ropid_departures_presets_old;
30
+
31
+
32
+ CREATE OR REPLACE VIEW analytic.v_ropid_departure_boards
33
+ AS SELECT final.lon,
34
+ final.lat,
35
+ final.route_name,
36
+ final.note,
37
+ final.stop_correct,
38
+ count(1) OVER (PARTITION BY (split_part(final.stop_correct, '/'::text, 1))) AS n_ceduli,
39
+ final.alt_idos_name
40
+ FROM ( SELECT stops.lon,
41
+ stops.lat,
42
+ tab.route_name,
43
+ tab.note,
44
+ tab.stop_correct,
45
+ stops.alt_idos_name,
46
+ row_number() OVER (PARTITION BY tab.note) AS n_duplicit
47
+ FROM ( SELECT rdp.route_name,
48
+ rdp.note,
49
+ CASE
50
+ WHEN rdp.url_query_params::text ~~ '%aswIds%'::text THEN replace("substring"(rdp.url_query_params::text, 'aswIds[^=]*?=(.+?(?=&|$))'::text), '_'::text, '/'::text)
51
+ WHEN rdp.url_query_params::text ~~ '%cisIds%'::text THEN "substring"(rdp.url_query_params::text, 'cisIds[^=]*?=(.+?(?=&|$))'::text)
52
+ ELSE NULL::text
53
+ END AS stop_correct
54
+ FROM ropid_departures_presets rdp) tab
55
+ LEFT JOIN ropidgtfs_cis_stops stops ON
56
+ CASE
57
+ WHEN tab.stop_correct ~~ '%/%'::text THEN tab.stop_correct = stops.id::text
58
+ ELSE tab.stop_correct = split_part(stops.id::text, '/'::text, 1)
59
+ END OR tab.stop_correct = stops.cis::text) final
60
+ WHERE final.n_duplicit = 1
61
+ ORDER BY final.stop_correct;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/pid",
3
- "version": "2.7.12-dev.937273478",
3
+ "version": "2.7.12-dev.938565701",
4
4
  "description": "Golemio PID Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",