@golemio/pid 2.13.2-dev.1288800468 → 2.13.2-dev.1289736387

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', '20240509102153-update-v-vehiclepositions-past-stop-times-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', '20240509102153-update-v-vehiclepositions-past-stop-times-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,42 @@
1
+ CREATE OR REPLACE VIEW v_vehiclepositions_past_stop_times
2
+ AS SELECT sub.trips_id AS rt_trip_id,
3
+ sub.last_stop_sequence AS stop_sequence,
4
+ sub.last_stop_id AS stop_id,
5
+ sub.last_stop_arrival_time AS stop_arrival,
6
+ sub.last_stop_departure_time AS stop_departure,
7
+ min(sub.delay_stop_arrival) AS stop_arr_delay,
8
+ max(sub.delay_stop_departure) AS stop_dep_delay
9
+ FROM ( SELECT rt_position.trips_id,
10
+ rt_position.last_stop_sequence,
11
+ rt_position.last_stop_id,
12
+ rt_position.last_stop_arrival_time,
13
+ rt_position.last_stop_departure_time,
14
+ rt_position.delay_stop_arrival,
15
+ rt_position.delay_stop_departure,
16
+ row_number() OVER seq AS rn
17
+ FROM vehiclepositions_positions rt_position
18
+ WHERE (rt_position.delay_stop_arrival IS NOT NULL OR rt_position.delay_stop_departure IS NOT NULL) AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
19
+ WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
20
+ WHERE sub.rn = 1
21
+ GROUP BY sub.trips_id, sub.last_stop_arrival_time, sub.last_stop_departure_time, sub.last_stop_sequence, sub.last_stop_id
22
+ ORDER BY sub.trips_id, sub.last_stop_sequence;
23
+
24
+
25
+ CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times
26
+ AS SELECT sub.trips_id AS rt_trip_id,
27
+ sub.last_stop_sequence AS stop_sequence,
28
+ min(sub.delay_stop_arrival) AS stop_arr_delay,
29
+ max(sub.delay_stop_departure) AS stop_dep_delay,
30
+ sub.last_stop_id AS stop_id
31
+ FROM ( SELECT rt_position.trips_id,
32
+ rt_position.last_stop_id,
33
+ rt_position.last_stop_sequence,
34
+ rt_position.delay_stop_arrival,
35
+ rt_position.delay_stop_departure,
36
+ row_number() OVER seq AS rn
37
+ FROM vehiclepositions_positions rt_position
38
+ WHERE (rt_position.delay_stop_arrival IS NOT NULL OR rt_position.delay_stop_departure IS NOT NULL) AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying, 'at_stop'::character varying, 'after_track'::character varying]::text[]))
39
+ WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
40
+ WHERE sub.rn = 1
41
+ GROUP BY sub.trips_id, sub.last_stop_sequence, sub.last_stop_id
42
+ ORDER BY sub.trips_id, sub.last_stop_sequence;
@@ -0,0 +1,42 @@
1
+ CREATE OR REPLACE VIEW v_vehiclepositions_past_stop_times
2
+ AS SELECT sub.trips_id AS rt_trip_id,
3
+ sub.last_stop_sequence AS stop_sequence,
4
+ sub.last_stop_id AS stop_id,
5
+ sub.last_stop_arrival_time AS stop_arrival,
6
+ sub.last_stop_departure_time AS stop_departure,
7
+ max(sub.delay_stop_arrival) AS stop_arr_delay,
8
+ min(sub.delay_stop_departure) AS stop_dep_delay
9
+ FROM ( SELECT rt_position.trips_id,
10
+ rt_position.last_stop_sequence,
11
+ rt_position.last_stop_id,
12
+ rt_position.last_stop_arrival_time,
13
+ rt_position.last_stop_departure_time,
14
+ rt_position.delay_stop_arrival,
15
+ rt_position.delay_stop_departure,
16
+ row_number() OVER seq AS rn
17
+ FROM vehiclepositions_positions rt_position
18
+ WHERE (rt_position.delay_stop_arrival IS NOT NULL OR rt_position.delay_stop_departure IS NOT NULL) AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
19
+ WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
20
+ WHERE sub.rn = 1
21
+ GROUP BY sub.trips_id, sub.last_stop_arrival_time, sub.last_stop_departure_time, sub.last_stop_sequence, sub.last_stop_id
22
+ ORDER BY sub.trips_id, sub.last_stop_sequence;
23
+
24
+
25
+ CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times
26
+ AS SELECT sub.trips_id AS rt_trip_id,
27
+ sub.last_stop_sequence AS stop_sequence,
28
+ max(sub.delay_stop_arrival) AS stop_arr_delay,
29
+ min(sub.delay_stop_departure) AS stop_dep_delay,
30
+ sub.last_stop_id AS stop_id
31
+ FROM ( SELECT rt_position.trips_id,
32
+ rt_position.last_stop_id,
33
+ rt_position.last_stop_sequence,
34
+ rt_position.delay_stop_arrival,
35
+ rt_position.delay_stop_departure,
36
+ row_number() OVER seq AS rn
37
+ FROM vehiclepositions_positions rt_position
38
+ WHERE (rt_position.delay_stop_arrival IS NOT NULL OR rt_position.delay_stop_departure IS NOT NULL) AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying, 'at_stop'::character varying, 'after_track'::character varying]::text[]))
39
+ WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
40
+ WHERE sub.rn = 1
41
+ GROUP BY sub.trips_id, sub.last_stop_sequence, sub.last_stop_id
42
+ ORDER BY sub.trips_id, sub.last_stop_sequence;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/pid",
3
- "version": "2.13.2-dev.1288800468",
3
+ "version": "2.13.2-dev.1289736387",
4
4
  "description": "Golemio PID Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",