@golemio/ndic 1.6.7 → 1.6.8-dev.2506413089

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', '20260506101336-optimize-traffic-restrictions-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', '20260506101336-optimize-traffic-restrictions-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,19 @@
1
+ create or replace function fetch_valid_traffic_restrictions(validity_datetime timestamptz)
2
+ returns setof v_traffic_restrictions_all
3
+ language sql
4
+ set search_path from current
5
+ as $function$
6
+ select distinct on (situation_record_id) *
7
+ from v_traffic_restrictions_all valid_rows
8
+ where
9
+ validity_overall_start_time < validity_datetime
10
+ and validity_overall_end_time > validity_datetime
11
+ and not exists (
12
+ select 1
13
+ from v_traffic_restrictions_all
14
+ where
15
+ situation_record_id = valid_rows.situation_record_id
16
+ and situation_record_version_time > valid_rows.situation_record_version_time
17
+ )
18
+ order by situation_record_id, situation_record_version_time desc
19
+ $function$;
@@ -0,0 +1,22 @@
1
+ CREATE OR REPLACE FUNCTION fetch_valid_traffic_restrictions(validity_datetime timestamp with time zone)
2
+ RETURNS SETOF v_traffic_restrictions_all
3
+ LANGUAGE sql
4
+ PARALLEL SAFE
5
+ set search_path from current
6
+ AS $function$
7
+ WITH valid_latest AS (
8
+ SELECT DISTINCT ON (situation_record_id) *
9
+ FROM v_traffic_restrictions_all
10
+ WHERE validity_overall_start_time < validity_datetime
11
+ AND validity_overall_end_time > validity_datetime
12
+ )
13
+ SELECT *
14
+ FROM valid_latest v
15
+ WHERE NOT EXISTS (
16
+ SELECT 1
17
+ FROM v_traffic_restrictions_all
18
+ WHERE situation_record_id = v.situation_record_id
19
+ AND situation_record_version_time > v.situation_record_version_time
20
+ )
21
+ ORDER BY situation_id, situation_record_id DESC;
22
+ $function$;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/ndic",
3
- "version": "1.6.7",
3
+ "version": "1.6.8-dev.2506413089",
4
4
  "description": "Golemio NDIC Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",