@golemio/pid 2.13.9-dev.1319660569 → 2.13.9-dev.1321189794

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', '20240604141644-fixing-view-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', '20240604141644-fixing-view-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,49 @@
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
+ sub.last_stop_name as stop_name,
10
+ sub.lat as lat,
11
+ sub.lng as lng
12
+ FROM ( SELECT rt_position.trips_id,
13
+ rt_position.last_stop_sequence,
14
+ rt_position.last_stop_id,
15
+ rt_position.last_stop_arrival_time,
16
+ rt_position.last_stop_departure_time,
17
+ rt_position.delay_stop_arrival,
18
+ rt_position.delay_stop_departure,
19
+ rt_position.last_stop_name,
20
+ rs.stop_lat as lat,
21
+ rs.stop_lon as lng,
22
+ row_number() OVER seq AS rn
23
+ FROM vehiclepositions_positions rt_position
24
+ JOIN ropidgtfs_stops rs ON rs.stop_id = rt_position.last_stop_id
25
+ 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]))
26
+ WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
27
+ WHERE sub.rn = 1
28
+ GROUP BY sub.trips_id, sub.last_stop_arrival_time, sub.last_stop_departure_time, sub.last_stop_sequence, sub.last_stop_id, sub.last_stop_name, sub.lat, sub.lng
29
+ ORDER BY sub.trips_id, sub.last_stop_sequence;
30
+
31
+
32
+ CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times
33
+ AS SELECT sub.trips_id AS rt_trip_id,
34
+ sub.last_stop_sequence AS stop_sequence,
35
+ max(sub.delay_stop_arrival) AS stop_arr_delay,
36
+ min(sub.delay_stop_departure) AS stop_dep_delay,
37
+ sub.last_stop_id AS stop_id
38
+ FROM ( SELECT rt_position.trips_id,
39
+ rt_position.last_stop_id,
40
+ rt_position.last_stop_sequence,
41
+ rt_position.delay_stop_arrival,
42
+ rt_position.delay_stop_departure,
43
+ row_number() OVER seq AS rn
44
+ FROM vehiclepositions_positions rt_position
45
+ 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[]))
46
+ WINDOW seq AS (PARTITION BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.state_position ORDER BY rt_position.id)) sub
47
+ WHERE sub.rn = 1
48
+ GROUP BY sub.trips_id, sub.last_stop_sequence, sub.last_stop_id
49
+ ORDER BY sub.trips_id, sub.last_stop_sequence;
@@ -0,0 +1,44 @@
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
+ sub.stop_arr_delay,
8
+ sub.stop_dep_delay,
9
+ sub.last_stop_name AS stop_name,
10
+ sub.lat,
11
+ sub.lng
12
+ FROM ( SELECT rt_position.trips_id,
13
+ rt_position.last_stop_sequence,
14
+ rt_position.last_stop_id,
15
+ rt_position.last_stop_arrival_time,
16
+ rt_position.last_stop_departure_time,
17
+ rt_position.last_stop_name,
18
+ rs.stop_lat AS lat,
19
+ rs.stop_lon AS lng,
20
+ max(rt_position.delay_stop_arrival) AS stop_arr_delay,
21
+ min(rt_position.delay_stop_departure) AS stop_dep_delay
22
+ FROM vehiclepositions_positions rt_position
23
+ JOIN ropidgtfs_stops rs ON rs.stop_id::text = rt_position.last_stop_id::text
24
+ 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]))
25
+ GROUP BY rt_position.trips_id, rt_position.last_stop_sequence, rt_position.last_stop_id, rt_position.last_stop_arrival_time, rt_position.last_stop_departure_time, rt_position.last_stop_name, rs.stop_lat, rs.stop_lon) sub
26
+ ORDER BY sub.trips_id, sub.last_stop_sequence;
27
+
28
+ CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times
29
+ AS SELECT sub.trips_id AS rt_trip_id,
30
+ sub.last_stop_sequence AS stop_sequence,
31
+ sub.stop_arr_delay,
32
+ sub.stop_dep_delay,
33
+ sub.last_stop_id AS stop_id
34
+ FROM ( SELECT rt_position.trips_id,
35
+ rt_position.last_stop_id,
36
+ rt_position.last_stop_sequence,
37
+ rt_position.delay_stop_arrival,
38
+ rt_position.delay_stop_departure,
39
+ max(rt_position.delay_stop_arrival) AS stop_arr_delay,
40
+ min(rt_position.delay_stop_departure) AS stop_dep_delay
41
+ FROM vehiclepositions_positions rt_position
42
+ 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]))
43
+ GROUP BY rt_position.trips_id, rt_position.last_stop_id, rt_position.last_stop_sequence, rt_position.delay_stop_arrival, rt_position.delay_stop_departure) sub
44
+ 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.9-dev.1319660569",
3
+ "version": "2.13.9-dev.1321189794",
4
4
  "description": "Golemio PID Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",