@golemio/pid 2.14.2-dev.1355461560 → 2.14.2-dev.1356992619

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', '20240701093122-fix-delay-in-view-v-public-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', '20240701093122-fix-delay-in-view-v-public-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,31 @@
1
+ CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times AS
2
+ SELECT
3
+ sub.trips_id AS rt_trip_id,
4
+ sub.last_stop_sequence AS stop_sequence,
5
+ sub.stop_arr_delay,
6
+ sub.stop_dep_delay,
7
+ sub.last_stop_id AS stop_id
8
+ FROM (
9
+ SELECT
10
+ rt_position.trips_id,
11
+ rt_position.last_stop_id,
12
+ rt_position.last_stop_sequence,
13
+ rt_position.delay_stop_arrival,
14
+ rt_position.delay_stop_departure,
15
+ max(rt_position.delay_stop_arrival) AS stop_arr_delay,
16
+ min(rt_position.delay_stop_departure) AS stop_dep_delay
17
+ FROM
18
+ vehiclepositions_positions rt_position
19
+ WHERE (rt_position.delay_stop_arrival IS NOT NULL
20
+ OR rt_position.delay_stop_departure IS NOT NULL)
21
+ AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
22
+ GROUP BY
23
+ rt_position.trips_id,
24
+ rt_position.last_stop_id,
25
+ rt_position.last_stop_sequence,
26
+ rt_position.delay_stop_arrival,
27
+ rt_position.delay_stop_departure) sub
28
+ ORDER BY
29
+ sub.trips_id,
30
+ sub.last_stop_sequence;
31
+
@@ -0,0 +1,38 @@
1
+ CREATE OR REPLACE VIEW v_public_vehiclepositions_past_stop_times AS
2
+ SELECT
3
+ sub.trips_id AS rt_trip_id,
4
+ sub.last_stop_sequence AS stop_sequence,
5
+ sub.stop_arr_delay,
6
+ sub.stop_dep_delay,
7
+ sub.last_stop_id AS stop_id
8
+ FROM (
9
+ SELECT
10
+ rt_position.trips_id,
11
+ rt_position.last_stop_id,
12
+ rt_position.last_stop_sequence,
13
+ CASE WHEN (rt_position.last_stop_departure_time::time +(interval '1 second' * min(rt_position.delay_stop_departure)) > rt_position.next_stop_arrival_time::time +(interval '1 second' * max(rt_position.delay_stop_arrival))) THEN
14
+ NULL
15
+ ELSE
16
+ max(rt_position.delay_stop_arrival)
17
+ END AS stop_arr_delay,
18
+ CASE WHEN (rt_position.last_stop_arrival_time::time +(interval '1 second' * max(rt_position.delay_stop_arrival)) > rt_position.last_stop_departure_time::time +(interval '1 second' * min(rt_position.delay_stop_departure))) THEN
19
+ NULL
20
+ ELSE
21
+ min(rt_position.delay_stop_departure)
22
+ END AS stop_dep_delay
23
+ FROM
24
+ vehiclepositions_positions rt_position
25
+ WHERE (rt_position.delay_stop_arrival IS NOT NULL
26
+ OR rt_position.delay_stop_departure IS NOT NULL)
27
+ AND (rt_position.state_position::text = ANY (ARRAY['on_track'::character varying::text, 'at_stop'::character varying::text, 'after_track'::character varying::text]))
28
+ GROUP BY
29
+ rt_position.trips_id,
30
+ rt_position.last_stop_id,
31
+ rt_position.last_stop_sequence,
32
+ rt_position.last_stop_arrival_time,
33
+ rt_position.last_stop_departure_time,
34
+ rt_position.next_stop_arrival_time) sub
35
+ ORDER BY
36
+ sub.trips_id,
37
+ sub.last_stop_sequence;
38
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/pid",
3
- "version": "2.14.2-dev.1355461560",
3
+ "version": "2.14.2-dev.1356992619",
4
4
  "description": "Golemio PID Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",