mirror of
https://github.com/xbgmsharp/postgsail.git
synced 2025-09-17 11:17:46 +00:00
Add unit tests mocha and sql
This commit is contained in:
85
tests/sql/badges.sql
Normal file
85
tests/sql/badges.sql
Normal file
@@ -0,0 +1,85 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
SELECT v.vessel_id as "vessel_id" FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud' \gset
|
||||
--\echo :"vessel_id"
|
||||
SELECT set_config('vessel.id', :'vessel_id', false) IS NOT NULL as vessel_id;
|
||||
|
||||
\echo 'Insert new api.logbook for badges'
|
||||
INSERT INTO api.logbook
|
||||
(id, active, "name", "_from", "_from_lat", "_from_lng", "_to", "_to_lat", "_to_lng", track_geom, track_geog, track_geojson, "_from_time", "_to_time", distance, duration, avg_speed, max_speed, max_wind_speed, notes, vessel_id)
|
||||
VALUES
|
||||
(nextval('api.logbook_id_seq'), false, 'Tropics Zone', NULL, NULL, NULL, NULL, NULL, NULL, 'SRID=4326;LINESTRING (-63.151124640791096 14.01074681627324, -77.0912026418618 12.870995731013664)'::public.geometry, NULL, NULL, NOW(), NOW(), 123, NULL, NULL, NULL, NULL, NULL, current_setting('vessel.id', false)),
|
||||
(nextval('api.logbook_id_seq'), false, 'Alaska Zone', NULL, NULL, NULL, NULL, NULL, NULL, 'SRID=4326;LINESTRING (-143.5773697471158 59.4404631255976, -152.35402122385003 56.58243132943173)'::public.geometry, NULL, NULL, NOW(), NOW(), 1234, NULL, NULL, NULL, NULL, NULL, current_setting('vessel.id', false));
|
||||
|
||||
\echo 'Set config'
|
||||
SELECT set_config('user.email', 'demo+kapla@openplotter.cloud', false);
|
||||
--SELECT set_config('vessel.client_id', 'vessels.urn:mrn:imo:mmsi:123456789', false);
|
||||
|
||||
\echo 'Process badge'
|
||||
SELECT badges_logbook_fn(5);
|
||||
SELECT badges_logbook_fn(6);
|
||||
SELECT badges_geom_fn(5);
|
||||
SELECT badges_geom_fn(6);
|
||||
|
||||
\echo 'Check badges for user'
|
||||
SELECT jsonb_object_keys ( a.preferences->'badges' ) FROM auth.accounts a;
|
||||
|
||||
\echo 'Check details from vessel_id kapla'
|
||||
--SELECT get_user_settings_from_vesselid_fn('vessels.urn:mrn:imo:mmsi:123456789'::TEXT);
|
||||
SELECT
|
||||
json_build_object(
|
||||
'boat', v.name,
|
||||
'recipient', a.first,
|
||||
'email', v.owner_email,
|
||||
--'settings', a.preferences,
|
||||
'pushover_key', a.preferences->'pushover_key'
|
||||
--'badges', a.preferences->'badges'
|
||||
) as user_settings
|
||||
FROM auth.accounts a, auth.vessels v, api.metadata m
|
||||
WHERE m.vessel_id = v.vessel_id
|
||||
AND m.vessel_id = current_setting('vessel.id', false)
|
||||
AND lower(a.email) = current_setting('user.email', false);
|
||||
|
||||
\echo 'Insert new api.moorages for badges'
|
||||
INSERT INTO api.moorages
|
||||
(id,"name",country,stay_id,stay_code,stay_duration,reference_count,latitude,longitude,geog,home_flag,notes,vessel_id)
|
||||
VALUES
|
||||
(5,'Badge Mooring Pro',NULL,5,3,'11 days 00:39:56.418',1,NULL,NULL,NULL,false,'Badge Mooring Pro',current_setting('vessel.id', false)),
|
||||
(6,'Badge Anchormaster',NULL,5,2,'26 days 00:49:56.418',1,NULL,NULL,NULL,false,'Badge Anchormaster',current_setting('vessel.id', false));
|
||||
|
||||
\echo 'Set config'
|
||||
SELECT set_config('user.email', 'demo+aava@openplotter.cloud', false);
|
||||
--SELECT set_config('vessel.client_id', 'vessels.urn:mrn:imo:mmsi:787654321', false);
|
||||
SELECT v.vessel_id as "vessel_id" FROM auth.vessels v WHERE v.owner_email = 'demo+aava@openplotter.cloud' \gset
|
||||
--\echo :"vessel_id"
|
||||
SELECT set_config('vessel.id', :'vessel_id', false) IS NOT NULL as vessel_id;
|
||||
|
||||
\echo 'Process badge'
|
||||
SELECT badges_moorages_fn();
|
||||
|
||||
\echo 'Check details from vessel_id aava'
|
||||
--SELECT get_user_settings_from_vesselid_fn('vessels.urn:mrn:imo:mmsi:787654321'::TEXT);
|
||||
SELECT
|
||||
json_build_object(
|
||||
'boat', v.name,
|
||||
'recipient', a.first,
|
||||
'email', v.owner_email,
|
||||
--'settings', a.preferences,
|
||||
'pushover_key', a.preferences->'pushover_key'
|
||||
--'badges', a.preferences->'badges'
|
||||
) as user_settings
|
||||
FROM auth.accounts a, auth.vessels v, api.metadata m
|
||||
WHERE m.vessel_id = v.vessel_id
|
||||
AND m.vessel_id = current_setting('vessel.id', false)
|
||||
AND lower(a.email) = current_setting('user.email', false);
|
82
tests/sql/badges.sql.output
Normal file
82
tests/sql/badges.sql.output
Normal file
@@ -0,0 +1,82 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
Insert new api.logbook for badges
|
||||
INSERT 0 2
|
||||
Set config
|
||||
-[ RECORD 1 ]----------------------------
|
||||
set_config | demo+kapla@openplotter.cloud
|
||||
|
||||
Process badge
|
||||
-[ RECORD 1 ]-----+-
|
||||
badges_logbook_fn |
|
||||
|
||||
-[ RECORD 1 ]-----+-
|
||||
badges_logbook_fn |
|
||||
|
||||
-[ RECORD 1 ]--+-
|
||||
badges_geom_fn |
|
||||
|
||||
-[ RECORD 1 ]--+-
|
||||
badges_geom_fn |
|
||||
|
||||
Check badges for user
|
||||
-[ RECORD 1 ]-----+------------------
|
||||
jsonb_object_keys | Helmsman
|
||||
-[ RECORD 2 ]-----+------------------
|
||||
jsonb_object_keys | Wake Maker
|
||||
-[ RECORD 3 ]-----+------------------
|
||||
jsonb_object_keys | Balearic Sea
|
||||
-[ RECORD 4 ]-----+------------------
|
||||
jsonb_object_keys | Stormtrooper
|
||||
-[ RECORD 5 ]-----+------------------
|
||||
jsonb_object_keys | Gulf of Finland
|
||||
-[ RECORD 6 ]-----+------------------
|
||||
jsonb_object_keys | Helmsman
|
||||
-[ RECORD 7 ]-----+------------------
|
||||
jsonb_object_keys | Wake Maker
|
||||
-[ RECORD 8 ]-----+------------------
|
||||
jsonb_object_keys | Club Alaska
|
||||
-[ RECORD 9 ]-----+------------------
|
||||
jsonb_object_keys | Stormtrooper
|
||||
-[ RECORD 10 ]----+------------------
|
||||
jsonb_object_keys | Captain Award
|
||||
-[ RECORD 11 ]----+------------------
|
||||
jsonb_object_keys | Caribbean Sea
|
||||
-[ RECORD 12 ]----+------------------
|
||||
jsonb_object_keys | Gulf of Alaska
|
||||
-[ RECORD 13 ]----+------------------
|
||||
jsonb_object_keys | Gulf of Finland
|
||||
-[ RECORD 14 ]----+------------------
|
||||
jsonb_object_keys | Navigator Award
|
||||
-[ RECORD 15 ]----+------------------
|
||||
jsonb_object_keys | Tropical Traveler
|
||||
|
||||
Check details from vessel_id kapla
|
||||
-[ RECORD 1 ]-+-----------------------------------------------------------------------------------------------------------------
|
||||
user_settings | {"boat" : "kapla", "recipient" : "First_kapla", "email" : "demo+kapla@openplotter.cloud", "pushover_key" : null}
|
||||
|
||||
Insert new api.moorages for badges
|
||||
INSERT 0 2
|
||||
Set config
|
||||
-[ RECORD 1 ]---------------------------
|
||||
set_config | demo+aava@openplotter.cloud
|
||||
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
Process badge
|
||||
-[ RECORD 1 ]------+-
|
||||
badges_moorages_fn |
|
||||
|
||||
Check details from vessel_id aava
|
||||
-[ RECORD 1 ]-+--------------------------------------------------------------------------------------------------------------
|
||||
user_settings | {"boat" : "aava", "recipient" : "first_aava", "email" : "demo+aava@openplotter.cloud", "pushover_key" : null}
|
||||
|
43
tests/sql/cron_post_jobs.sql
Normal file
43
tests/sql/cron_post_jobs.sql
Normal file
@@ -0,0 +1,43 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
-- set user_id
|
||||
SELECT a.user_id as "user_id" FROM auth.accounts a WHERE a.email = 'demo+kapla@openplotter.cloud' \gset
|
||||
--\echo :"user_id"
|
||||
SELECT set_config('user.id', :'user_id', false) IS NOT NULL as user_id;
|
||||
|
||||
-- set vessel_id
|
||||
SELECT v.vessel_id as "vessel_id" FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud' \gset
|
||||
--\echo :"vessel_id"
|
||||
SELECT set_config('vessel.id', :'vessel_id', false) IS NOT NULL as vessel_id;
|
||||
|
||||
-- Test logbook for user
|
||||
\echo 'logbook'
|
||||
SELECT count(*) FROM api.logbook WHERE vessel_id = current_setting('vessel.id', false);
|
||||
\echo 'logbook'
|
||||
SELECT name,_from_time IS NOT NULL AS _from_time,_to_time IS NOT NULL AS _to_time, track_geojson IS NOT NULL AS track_geojson, track_gpx IS NOT NULL AS track_gpx, track_geom, distance,duration,avg_speed,max_speed,max_wind_speed,notes,extra FROM api.logbook WHERE vessel_id = current_setting('vessel.id', false);
|
||||
|
||||
-- Test stays for user
|
||||
\echo 'stays'
|
||||
SELECT count(*) FROM api.stays WHERE vessel_id = current_setting('vessel.id', false);
|
||||
\echo 'stays'
|
||||
SELECT active,name,geog,stay_code FROM api.stays WHERE vessel_id = current_setting('vessel.id', false);
|
||||
|
||||
-- Test event logs view for user
|
||||
\echo 'eventlogs_view'
|
||||
select count(*) from api.eventlogs_view;
|
||||
|
||||
-- Test event logs view for user
|
||||
\echo 'stats_logs_fn'
|
||||
select api.stats_logs_fn(null, null);
|
||||
select api.stats_logs_fn('2022-01-01'::text,'2022-06-12'::text);
|
79
tests/sql/cron_post_jobs.sql.output
Normal file
79
tests/sql/cron_post_jobs.sql.output
Normal file
@@ -0,0 +1,79 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
-[ RECORD 1 ]
|
||||
user_id | t
|
||||
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
logbook
|
||||
-[ RECORD 1 ]
|
||||
count | 2
|
||||
|
||||
logbook
|
||||
-[ RECORD 1 ]--+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
name | Bollsta to Strandallén
|
||||
_from_time | t
|
||||
_to_time | t
|
||||
track_geojson | t
|
||||
track_gpx | t
|
||||
track_geom | 0102000020E61000001A00000020D26F5F0786374030BB270F0B094E400C6E7ED60F843740AA60545227084E40D60FC48C03823740593CE27D42074E407B39D9F322803740984C158C4A064E4091ED7C3F357E3740898BB63D54054E40A8A1208B477C37404BA3DC9059044E404C5CB4EDA17A3740C4F856115B034E40A9A44E4013793740D8F0F44A59024E40E4839ECDAA773740211FF46C56014E405408D147067637408229F03B73004E40787AA52C43743740F90FE9B7AFFF4D40F8098D4D18723740C217265305FF4D4084E82303537037409A2D464AA0FE4D4022474DCE636F37402912396A72FE4D408351499D806E374088CFB02B40FE4D4076711B0DE06D3740B356C7040FFE4D404EAC66B0BC6E374058A835CD3BFE4D40D7A3703D0A6F3740D3E10EC15EFE4D4087602F277B6E3740A779C7293AFE4D4087602F277B6E3740A779C7293AFE4D402063EE5A426E3740B5A679C729FE4D40381DEE10EC6D37409ECA7C1A0AFE4D40E2C46A06CB6B37400A43F7BF36FD4D4075931804566E3740320BDAD125FD4D409A2D464AA06E37404A5658830AFD4D40029A081B9E6E37404A5658830AFD4D40
|
||||
distance | 7.17
|
||||
duration | 00:25:00
|
||||
avg_speed | 3.6961538461538455
|
||||
max_speed | 6.1
|
||||
max_wind_speed | 22.1
|
||||
notes | new log note
|
||||
extra | {"metrics": {"propulsion.main.runTime": 10}, "observations": {"seaState": -1, "visibility": -1, "cloudCoverage": -1}}
|
||||
-[ RECORD 2 ]--+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
name | Knipan to Ekenäs
|
||||
_from_time | t
|
||||
_to_time | t
|
||||
track_geojson | t
|
||||
track_gpx | t
|
||||
track_geom | 0102000020E6100000130000004806A6C0EF6C3740DA1B7C6132FD4D40FE65F7E461693740226C787AA5FC4D407DD3E10EC1663740B29DEFA7C6FB4D40898BB63D5465374068479724BCFA4D409A5271F6E1633740B6847CD0B3F94D40431CEBE236623740E9263108ACF84D402C6519E2585F37407E678EBFC7F74D4096218E75715B374027C5B45C23F74D402AA913D044583740968DE1C46AF64D405AF5B9DA8A5537407BEF829B9FF54D407449C2ABD253374086C954C1A8F44D407D1A0AB278543740F2B0506B9AF34D409D11A5BDC15737406688635DDCF24D4061C3D32B655937402CAF6F3ADCF14D408988888888583740B3319C58CDF04D4021FAC8C0145837408C94405DB7EF4D40B8F9593F105B37403DC0804BEDEE4D40DE4C5FE2A25D3740AE47E17A14EE4D40DE4C5FE2A25D3740AE47E17A14EE4D40
|
||||
distance | 8.6862
|
||||
duration | 00:18:00
|
||||
avg_speed | 6.026315789473684
|
||||
max_speed | 6.5
|
||||
max_wind_speed | 37.2
|
||||
notes |
|
||||
extra | {"metrics": {"propulsion.main.runTime": 11}, "observations": {"seaState": -1, "visibility": -1, "cloudCoverage": -1}}
|
||||
|
||||
stays
|
||||
-[ RECORD 1 ]
|
||||
count | 3
|
||||
|
||||
stays
|
||||
-[ RECORD 1 ]-------------------------------------------------
|
||||
active | f
|
||||
name | Bollsta
|
||||
geog | 0101000020E6100000B0DEBBE0E68737404DA938FBF0094E40
|
||||
stay_code | 2
|
||||
-[ RECORD 2 ]-------------------------------------------------
|
||||
active | f
|
||||
name | Strandallén
|
||||
geog | 0101000020E6100000029A081B9E6E37404A5658830AFD4D40
|
||||
stay_code | 1
|
||||
-[ RECORD 3 ]-------------------------------------------------
|
||||
active | t
|
||||
name | Ekenäs
|
||||
geog | 0101000020E6100000DE4C5FE2A25D3740AE47E17A14EE4D40
|
||||
stay_code | 2
|
||||
|
||||
eventlogs_view
|
||||
-[ RECORD 1 ]
|
||||
count | 13
|
||||
|
||||
stats_logs_fn
|
||||
-[ RECORD 1 ]-+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
stats_logs_fn | {"count": 4, "max_speed": 7.1, "max_distance": 8.6862, "max_duration": "01:11:00", "max_speed_id": 3, "sum_duration": "02:37:00", "max_wind_speed": 44.2, "max_distance_id": 2, "max_wind_speed_id": 4}
|
||||
|
||||
-[ RECORD 1 ]-+-
|
||||
stats_logs_fn |
|
||||
|
20
tests/sql/cron_run_jobs.sql
Normal file
20
tests/sql/cron_run_jobs.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
-- Check the number of process pending
|
||||
-- Should be 22
|
||||
SELECT count(*) as jobs from public.process_queue pq where pq.processed is null;
|
||||
--set role scheduler
|
||||
SELECT public.run_cron_jobs();
|
||||
-- Check any pending job
|
||||
SELECT count(*) as any_pending_jobs from public.process_queue pq where pq.processed is null;
|
16
tests/sql/cron_run_jobs.sql.output
Normal file
16
tests/sql/cron_run_jobs.sql.output
Normal file
@@ -0,0 +1,16 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
-[ RECORD 1 ]
|
||||
jobs | 28
|
||||
|
||||
-[ RECORD 1 ]-+-
|
||||
run_cron_jobs |
|
||||
|
||||
-[ RECORD 1 ]----+--
|
||||
any_pending_jobs | 0
|
||||
|
79
tests/sql/grafana.sql
Normal file
79
tests/sql/grafana.sql
Normal file
@@ -0,0 +1,79 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
--
|
||||
-- grafana_auth
|
||||
SET ROLE grafana_auth;
|
||||
\echo 'ROLE grafana_auth current_setting'
|
||||
SELECT current_user, current_setting('user.email', true), current_setting('vessel.client_id', true), current_setting('vessel.id', true);
|
||||
|
||||
--SELECT a.pass,v.name,m.client_id FROM auth.accounts a JOIN auth.vessels v ON a.email = 'demo+kapla@openplotter.cloud' AND a.role = 'user_role' AND cast(a.preferences->>'email_valid' as Boolean) = True AND v.owner_email = a.email JOIN api.metadata m ON m.vessel_id = v.vessel_id;
|
||||
--SELECT a.pass,v.name,m.client_id FROM auth.accounts a JOIN auth.vessels v ON a.email = 'demo+kapla@openplotter.cloud' AND a.role = 'user_role' AND v.owner_email = a.email JOIN api.metadata m ON m.vessel_id = v.vessel_id;
|
||||
\echo 'link vessel and user based on current_setting'
|
||||
SELECT v.name,m.client_id FROM auth.accounts a JOIN auth.vessels v ON a.role = 'user_role' AND v.owner_email = a.email JOIN api.metadata m ON m.vessel_id = v.vessel_id;
|
||||
|
||||
\echo 'auth.accounts details'
|
||||
SELECT a.userid IS NOT NULL AS userid, a.user_id IS NOT NULL AS user_id, a.email, a.first, a.last, a.pass IS NOT NULL AS pass, a.role, a.preferences->'telegram'->'chat' AS telegram, a.preferences->'pushover_user_key' AS pushover_user_key FROM auth.accounts AS a;
|
||||
\echo 'auth.vessels details'
|
||||
--SELECT 'SELECT ' || STRING_AGG('v.' || column_name, ', ') || ' FROM auth.vessels AS v' FROM information_schema.columns WHERE table_name = 'vessels' AND table_schema = 'auth' AND column_name NOT IN ('created_at', 'updated_at');
|
||||
SELECT v.vessel_id IS NOT NULL AS vessel_id, v.owner_email, v.mmsi, v.name, v.role FROM auth.vessels AS v;
|
||||
\echo 'api.metadata details'
|
||||
--
|
||||
SELECT m.id, m.name, m.mmsi, m.client_id, m.length, m.beam, m.height, m.ship_type, m.plugin_version, m.signalk_version, m.time IS NOT NULL AS time, m.active FROM api.metadata AS m;
|
||||
|
||||
--
|
||||
-- grafana
|
||||
SET ROLE grafana;
|
||||
\echo 'ROLE grafana current_setting'
|
||||
|
||||
\echo 'Set current_setting value'
|
||||
SET "user.email" = 'demo+kapla@openplotter.cloud';
|
||||
--SET vessel.client_id = 'vessels.urn:mrn:imo:mmsi:123456789';
|
||||
|
||||
--select v.vessel_id FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud';
|
||||
SELECT v.vessel_id as "vessel_id" FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud' \gset
|
||||
--\echo :"vessel_id"
|
||||
SELECT set_config('vessel.id', :'vessel_id', false) IS NOT NULL as vessel_id;
|
||||
|
||||
--SELECT current_user, current_setting('user.email', true), current_setting('vessel.client_id', true), current_setting('vessel.id', true);
|
||||
SELECT current_user, current_setting('user.email', true), current_setting('vessel.client_id', true);
|
||||
|
||||
SELECT v.name AS __text, m.client_id AS __value FROM auth.vessels v JOIN api.metadata m ON v.owner_email = 'demo+kapla@openplotter.cloud' and m.vessel_id = v.vessel_id;
|
||||
|
||||
\echo 'auth.vessels details'
|
||||
--SELECT * FROM auth.vessels v;
|
||||
SELECT v.vessel_id IS NOT NULL AS vessel_id, v.owner_email, v.mmsi, v.name, v.role FROM auth.vessels AS v;
|
||||
--SELECT * FROM api.metadata m;
|
||||
\echo 'api.metadata details'
|
||||
SELECT m.id, m.name, m.mmsi, m.client_id, m.length, m.beam, m.height, m.ship_type, m.plugin_version, m.signalk_version, m.time IS NOT NULL AS time, m.active FROM api.metadata AS m;
|
||||
|
||||
\echo 'api.logs_view'
|
||||
--SELECT * FROM api.logbook l;
|
||||
--SELECT * FROM api.logs_view l;
|
||||
SELECT l.id, "Name", "From", "To", "Distance", "Duration" FROM api.logs_view AS l;
|
||||
--SELECT * FROM api.log_view l;
|
||||
|
||||
\echo 'api.stays'
|
||||
--SELECT * FROM api.stays s;
|
||||
SELECT m.id, m.vessel_id IS NOT NULL AS vessel_id, m.active, m.name, m.latitude, m.longitude, m.geog, m.arrived IS NOT NULL AS arrived, m.departed IS NOT NULL AS departed, m.duration, m.stay_code, m.notes FROM api.stays AS m;
|
||||
|
||||
\echo 'stays_view'
|
||||
--SELECT * FROM api.stays_view s;
|
||||
SELECT m.id, m.name IS NOT NULL AS name, m.moorage, m.moorage_id, m.duration, m.stayed_at, m.stayed_at_id, m.arrived IS NOT NULL AS arrived, m.departed IS NOT NULL AS departed, m.notes FROM api.stays_view AS m;
|
||||
|
||||
\echo 'api.moorages'
|
||||
--SELECT * FROM api.moorages m;
|
||||
SELECT m.id, m.vessel_id IS NOT NULL AS vessel_id, m.name, m.country, m.stay_id, m.stay_code, m.stay_duration, m.reference_count, m.latitude, m.longitude, m.geog, m.home_flag, m.notes FROM api.moorages AS m;
|
||||
|
||||
\echo 'api.moorages_view'
|
||||
SELECT * FROM api.moorages_view s;
|
253
tests/sql/grafana.sql.output
Normal file
253
tests/sql/grafana.sql.output
Normal file
@@ -0,0 +1,253 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
SET
|
||||
ROLE grafana_auth current_setting
|
||||
-[ RECORD 1 ]---+-------------
|
||||
current_user | grafana_auth
|
||||
current_setting |
|
||||
current_setting |
|
||||
current_setting |
|
||||
|
||||
link vessel and user based on current_setting
|
||||
-[ RECORD 1 ]----------------------------------------------------------------
|
||||
name | kapla
|
||||
client_id | vessels.urn:mrn:signalk:uuid:5b4f7543-7153-4840-b139-761310b242fd
|
||||
-[ RECORD 2 ]----------------------------------------------------------------
|
||||
name | aava
|
||||
client_id | vessels.urn:mrn:imo:mmsi:787654321
|
||||
|
||||
auth.accounts details
|
||||
-[ RECORD 1 ]-----+-----------------------------
|
||||
userid | t
|
||||
user_id | t
|
||||
email | demo+kapla@openplotter.cloud
|
||||
first | First_kapla
|
||||
last | Last_kapla
|
||||
pass | t
|
||||
role | user_role
|
||||
telegram |
|
||||
pushover_user_key |
|
||||
-[ RECORD 2 ]-----+-----------------------------
|
||||
userid | t
|
||||
user_id | t
|
||||
email | demo+aava@openplotter.cloud
|
||||
first | first_aava
|
||||
last | last_aava
|
||||
pass | t
|
||||
role | user_role
|
||||
telegram |
|
||||
pushover_user_key |
|
||||
|
||||
auth.vessels details
|
||||
-[ RECORD 1 ]-----------------------------
|
||||
vessel_id | t
|
||||
owner_email | demo+kapla@openplotter.cloud
|
||||
mmsi |
|
||||
name | kapla
|
||||
role | vessel_role
|
||||
-[ RECORD 2 ]-----------------------------
|
||||
vessel_id | t
|
||||
owner_email | demo+aava@openplotter.cloud
|
||||
mmsi | 787654321
|
||||
name | aava
|
||||
role | vessel_role
|
||||
|
||||
api.metadata details
|
||||
-[ RECORD 1 ]---+------------------------------------------------------------------
|
||||
id | 1
|
||||
name | kapla
|
||||
mmsi | 123456789
|
||||
client_id | vessels.urn:mrn:signalk:uuid:5b4f7543-7153-4840-b139-761310b242fd
|
||||
length | 12
|
||||
beam | 10
|
||||
height | 24
|
||||
ship_type | 36
|
||||
plugin_version | 0.0.1
|
||||
signalk_version | signalk_version
|
||||
time | t
|
||||
active | t
|
||||
-[ RECORD 2 ]---+------------------------------------------------------------------
|
||||
id | 2
|
||||
name | aava
|
||||
mmsi | 787654321
|
||||
client_id | vessels.urn:mrn:imo:mmsi:787654321
|
||||
length | 12
|
||||
beam | 10
|
||||
height | 24
|
||||
ship_type | 37
|
||||
plugin_version | 1.0.2
|
||||
signalk_version | 1.20.0
|
||||
time | t
|
||||
active | t
|
||||
|
||||
SET
|
||||
ROLE grafana current_setting
|
||||
Set current_setting value
|
||||
SET
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
-[ RECORD 1 ]---+-----------------------------
|
||||
current_user | grafana
|
||||
current_setting | demo+kapla@openplotter.cloud
|
||||
current_setting |
|
||||
|
||||
-[ RECORD 1 ]--------------------------------------------------------------
|
||||
__text | kapla
|
||||
__value | vessels.urn:mrn:signalk:uuid:5b4f7543-7153-4840-b139-761310b242fd
|
||||
|
||||
auth.vessels details
|
||||
-[ RECORD 1 ]-----------------------------
|
||||
vessel_id | t
|
||||
owner_email | demo+kapla@openplotter.cloud
|
||||
mmsi |
|
||||
name | kapla
|
||||
role | vessel_role
|
||||
|
||||
api.metadata details
|
||||
-[ RECORD 1 ]---+------------------------------------------------------------------
|
||||
id | 1
|
||||
name | kapla
|
||||
mmsi | 123456789
|
||||
client_id | vessels.urn:mrn:signalk:uuid:5b4f7543-7153-4840-b139-761310b242fd
|
||||
length | 12
|
||||
beam | 10
|
||||
height | 24
|
||||
ship_type | 36
|
||||
plugin_version | 0.0.1
|
||||
signalk_version | signalk_version
|
||||
time | t
|
||||
active | t
|
||||
|
||||
api.logs_view
|
||||
-[ RECORD 1 ]--------------
|
||||
id | 2
|
||||
Name | Knipan to Ekenäs
|
||||
From | Knipan
|
||||
To | Ekenäs
|
||||
Distance | 8.6862
|
||||
Duration | 00:18:00
|
||||
-[ RECORD 2 ]--------------
|
||||
id | 1
|
||||
Name | patch log name 3
|
||||
From | Bollsta
|
||||
To | Strandallén
|
||||
Distance | 7.17
|
||||
Duration | 00:25:00
|
||||
|
||||
api.stays
|
||||
-[ RECORD 1 ]-------------------------------------------------
|
||||
id | 1
|
||||
vessel_id | t
|
||||
active | f
|
||||
name | patch stay name 3
|
||||
latitude | 60.077666666666666
|
||||
longitude | 23.530866666666668
|
||||
geog | 0101000020E6100000B0DEBBE0E68737404DA938FBF0094E40
|
||||
arrived | t
|
||||
departed | t
|
||||
duration |
|
||||
stay_code | 2
|
||||
notes | new stay note 3
|
||||
-[ RECORD 2 ]-------------------------------------------------
|
||||
id | 2
|
||||
vessel_id | t
|
||||
active | f
|
||||
name | Strandallén
|
||||
latitude | 59.97688333333333
|
||||
longitude | 23.4321
|
||||
geog | 0101000020E6100000029A081B9E6E37404A5658830AFD4D40
|
||||
arrived | t
|
||||
departed | t
|
||||
duration |
|
||||
stay_code | 1
|
||||
notes |
|
||||
-[ RECORD 3 ]-------------------------------------------------
|
||||
id | 3
|
||||
vessel_id | t
|
||||
active | t
|
||||
name | Ekenäs
|
||||
latitude | 59.86
|
||||
longitude | 23.365766666666666
|
||||
geog | 0101000020E6100000DE4C5FE2A25D3740AE47E17A14EE4D40
|
||||
arrived | t
|
||||
departed | f
|
||||
duration |
|
||||
stay_code | 2
|
||||
notes |
|
||||
|
||||
stays_view
|
||||
-[ RECORD 1 ]+------------------
|
||||
id | 2
|
||||
name | t
|
||||
moorage | Strandallén
|
||||
moorage_id | 2
|
||||
duration | 00:03:00
|
||||
stayed_at | Unknow
|
||||
stayed_at_id | 1
|
||||
arrived | t
|
||||
departed | t
|
||||
notes |
|
||||
-[ RECORD 2 ]+------------------
|
||||
id | 1
|
||||
name | t
|
||||
moorage | patch stay name 3
|
||||
moorage_id | 1
|
||||
duration | 00:02:00
|
||||
stayed_at | Anchor
|
||||
stayed_at_id | 2
|
||||
arrived | t
|
||||
departed | t
|
||||
notes | new stay note 3
|
||||
|
||||
api.moorages
|
||||
-[ RECORD 1 ]---+---------------------------------------------------
|
||||
id | 1
|
||||
vessel_id | t
|
||||
name | patch moorage name 3
|
||||
country |
|
||||
stay_id | 1
|
||||
stay_code | 2
|
||||
stay_duration | 00:02:00
|
||||
reference_count | 1
|
||||
latitude | 60.077666666666666
|
||||
longitude | 23.530866666666668
|
||||
geog | 0101000020E6100000B0DEBBE0E68737404DA938FBF0094E40
|
||||
home_flag | t
|
||||
notes | new moorage note 3
|
||||
-[ RECORD 2 ]---+---------------------------------------------------
|
||||
id | 2
|
||||
vessel_id | t
|
||||
name | Strandallén
|
||||
country |
|
||||
stay_id | 2
|
||||
stay_code | 1
|
||||
stay_duration | 00:03:00
|
||||
reference_count | 1
|
||||
latitude | 59.97688333333333
|
||||
longitude | 23.4321
|
||||
geog | 0101000020E6100000029A081B9E6E37404A5658830AFD4D40
|
||||
home_flag | f
|
||||
notes |
|
||||
|
||||
api.moorages_view
|
||||
-[ RECORD 1 ]-------+---------------------
|
||||
id | 1
|
||||
moorage | patch moorage name 3
|
||||
default_stay | Anchor
|
||||
default_stay_id | 2
|
||||
total_stay | 0
|
||||
arrivals_departures | 1
|
||||
-[ RECORD 2 ]-------+---------------------
|
||||
id | 2
|
||||
moorage | Strandallén
|
||||
default_stay | Unknow
|
||||
default_stay_id | 1
|
||||
total_stay | 0
|
||||
arrivals_departures | 1
|
||||
|
53
tests/sql/monitoring.sql
Normal file
53
tests/sql/monitoring.sql
Normal file
@@ -0,0 +1,53 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
\echo 'Set vessel_id and vessel.name'
|
||||
-- set vessel_id
|
||||
SELECT v.vessel_id as "vessel_id" FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud' \gset
|
||||
--\echo :"vessel_id"
|
||||
SELECT set_config('vessel.id', :'vessel_id', false) IS NOT NULL as vessel_id;
|
||||
|
||||
-- set name
|
||||
SELECT v.name as "name" FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud' \gset
|
||||
--\echo :"vessel_id"
|
||||
SELECT set_config('vessel.name', :'name', false) IS NOT NULL as name;
|
||||
|
||||
\echo 'Test monitoring_view for user'
|
||||
-- Test monitoring for user
|
||||
--select * from api.monitoring_view;
|
||||
select count(*) from api.monitoring_view;
|
||||
|
||||
\echo 'Test monitoring_view2 for user'
|
||||
-- Test monitoring for user
|
||||
--select * from api.monitoring_view2;
|
||||
select count(*) from api.monitoring_view2;
|
||||
|
||||
\echo 'Test monitoring_view3 for user'
|
||||
-- Test monitoring for user
|
||||
--select * from api.monitoring_view3;
|
||||
select count(*) from api.monitoring_view3;
|
||||
|
||||
\echo 'Test monitoring_voltage for user'
|
||||
-- Test monitoring for user
|
||||
--select * from api.monitoring_voltage;
|
||||
select count(*) from api.monitoring_voltage;
|
||||
|
||||
\echo 'Test monitoring_temperatures for user'
|
||||
-- Test monitoring for user
|
||||
--select * from api.monitoring_temperatures;
|
||||
select count(*) from api.monitoring_temperatures;
|
||||
|
||||
\echo 'Test monitoring_humidity for user'
|
||||
-- Test monitoring for user
|
||||
--select * from api.monitoring_humidity;
|
||||
select count(*) from api.monitoring_humidity;
|
38
tests/sql/monitoring.sql.output
Normal file
38
tests/sql/monitoring.sql.output
Normal file
@@ -0,0 +1,38 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
Set vessel_id and vessel.name
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
-[ RECORD 1 ]
|
||||
name | t
|
||||
|
||||
Test monitoring_view for user
|
||||
-[ RECORD 1 ]
|
||||
count | 1
|
||||
|
||||
Test monitoring_view2 for user
|
||||
-[ RECORD 1 ]
|
||||
count | 21
|
||||
|
||||
Test monitoring_view3 for user
|
||||
-[ RECORD 1 ]
|
||||
count | 3682
|
||||
|
||||
Test monitoring_voltage for user
|
||||
-[ RECORD 1 ]
|
||||
count | 46
|
||||
|
||||
Test monitoring_temperatures for user
|
||||
-[ RECORD 1 ]
|
||||
count | 119
|
||||
|
||||
Test monitoring_humidity for user
|
||||
-[ RECORD 1 ]
|
||||
count | 0
|
||||
|
26
tests/sql/otp.sql
Normal file
26
tests/sql/otp.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
--
|
||||
--
|
||||
\echo 'Count auth.accounts'
|
||||
SELECT count(*) from auth.accounts;
|
||||
\echo 'Settings auth.accounts'
|
||||
SELECT preferences->'email_notifications' as email_notifications from auth.accounts;
|
||||
SELECT preferences->'phone_notifications' as phone_notifications from auth.accounts;
|
||||
SELECT preferences->'telegram'->'chat'->'id' as telegram from auth.accounts;
|
||||
--SELECT preferences->'telegram'->'date' - INTERVAL 5 minutes from auth.accounts;
|
||||
|
||||
SELECT count(*)
|
||||
FROM auth.accounts
|
||||
WHERE preferences->'telegram'->'chat'->'id' is null;
|
30
tests/sql/otp.sql.output
Normal file
30
tests/sql/otp.sql.output
Normal file
@@ -0,0 +1,30 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
Count auth.accounts
|
||||
-[ RECORD 1 ]
|
||||
count | 2
|
||||
|
||||
Settings auth.accounts
|
||||
-[ RECORD 1 ]-------+------
|
||||
email_notifications | false
|
||||
-[ RECORD 2 ]-------+------
|
||||
email_notifications | false
|
||||
|
||||
-[ RECORD 1 ]-------+------
|
||||
phone_notifications | false
|
||||
-[ RECORD 2 ]-------+------
|
||||
phone_notifications | false
|
||||
|
||||
-[ RECORD 1 ]--------
|
||||
telegram | 1234567890
|
||||
-[ RECORD 2 ]--------
|
||||
telegram | 9876543210
|
||||
|
||||
-[ RECORD 1 ]
|
||||
count | 0
|
||||
|
88
tests/sql/summary.sql
Normal file
88
tests/sql/summary.sql
Normal file
@@ -0,0 +1,88 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
-- List PostgreSQL version
|
||||
SELECT version();
|
||||
|
||||
-- List Postgis version
|
||||
SELECT postgis_full_version();
|
||||
|
||||
-- List of installed extensions
|
||||
-- \dx
|
||||
--SELECT extname,extversion FROM pg_extension;
|
||||
SELECT e.extname AS "Name", e.extversion AS "Version", n.nspname AS "Schema", c.description AS "Description"
|
||||
FROM pg_catalog.pg_extension e
|
||||
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace
|
||||
LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass
|
||||
ORDER BY 1;
|
||||
|
||||
-- List of installed extensions available for upgrade
|
||||
SELECT name, default_version, installed_version FROM pg_available_extensions where default_version <> installed_version;
|
||||
|
||||
-- List Language
|
||||
\echo 'List Language'
|
||||
SELECT * FROM pg_language;
|
||||
|
||||
-- List of databases
|
||||
-- ICU Missing entry in some system?
|
||||
--\l
|
||||
SELECT datname,datconnlimit,datcollate,datctype,datallowconn FROM pg_database;
|
||||
|
||||
-- List of relations
|
||||
\echo 'List of relations'
|
||||
\dtables
|
||||
|
||||
-- List tables from schema api
|
||||
select t.table_name as schema_api
|
||||
from information_schema.tables t
|
||||
where t.table_schema = 'api'
|
||||
and t.table_type = 'BASE TABLE'
|
||||
order by t.table_name;
|
||||
|
||||
-- List tables from schema public
|
||||
select t.table_name as schema_public
|
||||
from information_schema.tables t
|
||||
where t.table_schema = 'public'
|
||||
and t.table_type = 'BASE TABLE'
|
||||
order by t.table_name;
|
||||
|
||||
-- List tables from schema auth
|
||||
select t.table_name as schema_auth
|
||||
from information_schema.tables t
|
||||
where t.table_schema = 'auth'
|
||||
and t.table_type = 'BASE TABLE'
|
||||
order by t.table_name;
|
||||
|
||||
-- List tables from schema jwt
|
||||
select t.table_name as schema_jwt
|
||||
from information_schema.tables t
|
||||
where t.table_schema = 'jwt'
|
||||
and t.table_type = 'BASE TABLE'
|
||||
order by t.table_name;
|
||||
|
||||
-- List Row Security Policies - todo reduce and improve output
|
||||
\echo 'List Row Security Policies'
|
||||
select * from pg_policies;
|
||||
|
||||
-- Test functions
|
||||
\echo 'Test nominatim reverse_geocode_py_fn'
|
||||
SELECT public.reverse_geocode_py_fn('nominatim', 1.4440116666666667, 38.82985166666667);
|
||||
\echo 'Test geoip reverse_geoip_py_fn'
|
||||
--SELECT reverse_geoip_py_fn('62.74.13.231');
|
||||
|
||||
-- List details product versions
|
||||
SELECT api.versions_fn();
|
||||
SELECT * FROM api.versions_view;
|
||||
|
||||
-- List application settings
|
||||
--SELECT * IS NOT NULl FROM public.app_settings;
|
608
tests/sql/summary.sql.output
Normal file
608
tests/sql/summary.sql.output
Normal file
@@ -0,0 +1,608 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
-[ RECORD 1 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
version | PostgreSQL 15.4 (Debian 15.4-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
|
||||
|
||||
-[ RECORD 1 ]--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
postgis_full_version | POSTGIS="3.4.0 0874ea3" [EXTENSION] PGSQL="150" GEOS="3.9.0-CAPI-1.16.2" PROJ="7.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/var/lib/postgresql/.local/share/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)"
|
||||
|
||||
-[ RECORD 1 ]--------------------------------------------------------------------------------------
|
||||
Name | citext
|
||||
Version | 1.6
|
||||
Schema | public
|
||||
Description | data type for case-insensitive character strings
|
||||
-[ RECORD 2 ]--------------------------------------------------------------------------------------
|
||||
Name | jsonb_plpython3u
|
||||
Version | 1.0
|
||||
Schema | public
|
||||
Description | transform between jsonb and plpython3u
|
||||
-[ RECORD 3 ]--------------------------------------------------------------------------------------
|
||||
Name | moddatetime
|
||||
Version | 1.0
|
||||
Schema | public
|
||||
Description | functions for tracking last modification time
|
||||
-[ RECORD 4 ]--------------------------------------------------------------------------------------
|
||||
Name | pg_stat_statements
|
||||
Version | 1.10
|
||||
Schema | public
|
||||
Description | track planning and execution statistics of all SQL statements executed
|
||||
-[ RECORD 5 ]--------------------------------------------------------------------------------------
|
||||
Name | pgcrypto
|
||||
Version | 1.3
|
||||
Schema | public
|
||||
Description | cryptographic functions
|
||||
-[ RECORD 6 ]--------------------------------------------------------------------------------------
|
||||
Name | plpgsql
|
||||
Version | 1.0
|
||||
Schema | pg_catalog
|
||||
Description | PL/pgSQL procedural language
|
||||
-[ RECORD 7 ]--------------------------------------------------------------------------------------
|
||||
Name | plpython3u
|
||||
Version | 1.0
|
||||
Schema | pg_catalog
|
||||
Description | PL/Python3U untrusted procedural language
|
||||
-[ RECORD 8 ]--------------------------------------------------------------------------------------
|
||||
Name | postgis
|
||||
Version | 3.4.0
|
||||
Schema | public
|
||||
Description | PostGIS geometry and geography spatial types and functions
|
||||
-[ RECORD 9 ]--------------------------------------------------------------------------------------
|
||||
Name | timescaledb
|
||||
Version | 2.11.2
|
||||
Schema | public
|
||||
Description | Enables scalable inserts and complex queries for time-series data (Community Edition)
|
||||
-[ RECORD 10 ]-------------------------------------------------------------------------------------
|
||||
Name | uuid-ossp
|
||||
Version | 1.1
|
||||
Schema | public
|
||||
Description | generate universally unique identifiers (UUIDs)
|
||||
|
||||
(0 rows)
|
||||
|
||||
List Language
|
||||
-[ RECORD 1 ]-+-----------
|
||||
oid | 12
|
||||
lanname | internal
|
||||
lanowner | 10
|
||||
lanispl | f
|
||||
lanpltrusted | f
|
||||
lanplcallfoid | 0
|
||||
laninline | 0
|
||||
lanvalidator | 2246
|
||||
lanacl |
|
||||
-[ RECORD 2 ]-+-----------
|
||||
oid | 13
|
||||
lanname | c
|
||||
lanowner | 10
|
||||
lanispl | f
|
||||
lanpltrusted | f
|
||||
lanplcallfoid | 0
|
||||
laninline | 0
|
||||
lanvalidator | 2247
|
||||
lanacl |
|
||||
-[ RECORD 3 ]-+-----------
|
||||
oid | 14
|
||||
lanname | sql
|
||||
lanowner | 10
|
||||
lanispl | f
|
||||
lanpltrusted | t
|
||||
lanplcallfoid | 0
|
||||
laninline | 0
|
||||
lanvalidator | 2248
|
||||
lanacl |
|
||||
-[ RECORD 4 ]-+-----------
|
||||
oid | 13542
|
||||
lanname | plpgsql
|
||||
lanowner | 10
|
||||
lanispl | t
|
||||
lanpltrusted | t
|
||||
lanplcallfoid | 13539
|
||||
laninline | 13540
|
||||
lanvalidator | 13541
|
||||
lanacl |
|
||||
-[ RECORD 5 ]-+-----------
|
||||
oid | 18174
|
||||
lanname | plpython3u
|
||||
lanowner | 10
|
||||
lanispl | t
|
||||
lanpltrusted | t
|
||||
lanplcallfoid | 18171
|
||||
laninline | 18172
|
||||
lanvalidator | 18173
|
||||
lanacl |
|
||||
|
||||
-[ RECORD 1 ]+-----------
|
||||
datname | postgres
|
||||
datconnlimit | -1
|
||||
datcollate | en_US.utf8
|
||||
datctype | en_US.utf8
|
||||
datallowconn | t
|
||||
-[ RECORD 2 ]+-----------
|
||||
datname | template1
|
||||
datconnlimit | -1
|
||||
datcollate | en_US.utf8
|
||||
datctype | en_US.utf8
|
||||
datallowconn | t
|
||||
-[ RECORD 3 ]+-----------
|
||||
datname | template0
|
||||
datconnlimit | -1
|
||||
datcollate | en_US.utf8
|
||||
datctype | en_US.utf8
|
||||
datallowconn | f
|
||||
-[ RECORD 4 ]+-----------
|
||||
datname | signalk
|
||||
datconnlimit | 100
|
||||
datcollate | en_US.utf8
|
||||
datctype | en_US.utf8
|
||||
datallowconn | t
|
||||
|
||||
List of relations
|
||||
List of relations
|
||||
-[ RECORD 1 ]---------------------------------
|
||||
Schema | public
|
||||
Name | aistypes
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 2 ]---------------------------------
|
||||
Schema | public
|
||||
Name | app_settings
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 3 ]---------------------------------
|
||||
Schema | public
|
||||
Name | badges
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 4 ]---------------------------------
|
||||
Schema | public
|
||||
Name | email_templates
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 5 ]---------------------------------
|
||||
Schema | public
|
||||
Name | geocoders
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 6 ]---------------------------------
|
||||
Schema | public
|
||||
Name | iso3166
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 7 ]---------------------------------
|
||||
Schema | public
|
||||
Name | mid
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 8 ]---------------------------------
|
||||
Schema | public
|
||||
Name | ne_10m_geography_marine_polys
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 9 ]---------------------------------
|
||||
Schema | public
|
||||
Name | ne_10m_geography_marine_polys_gid_seq
|
||||
Type | sequence
|
||||
Owner | username
|
||||
-[ RECORD 10 ]--------------------------------
|
||||
Schema | public
|
||||
Name | process_queue
|
||||
Type | table
|
||||
Owner | username
|
||||
-[ RECORD 11 ]--------------------------------
|
||||
Schema | public
|
||||
Name | process_queue_id_seq
|
||||
Type | sequence
|
||||
Owner | username
|
||||
-[ RECORD 12 ]--------------------------------
|
||||
Schema | public
|
||||
Name | spatial_ref_sys
|
||||
Type | table
|
||||
Owner | username
|
||||
|
||||
-[ RECORD 1 ]--------
|
||||
schema_api | logbook
|
||||
-[ RECORD 2 ]--------
|
||||
schema_api | metadata
|
||||
-[ RECORD 3 ]--------
|
||||
schema_api | metrics
|
||||
-[ RECORD 4 ]--------
|
||||
schema_api | moorages
|
||||
-[ RECORD 5 ]--------
|
||||
schema_api | stays
|
||||
-[ RECORD 6 ]--------
|
||||
schema_api | stays_at
|
||||
|
||||
-[ RECORD 1 ]-+------------------------------
|
||||
schema_public | aistypes
|
||||
-[ RECORD 2 ]-+------------------------------
|
||||
schema_public | app_settings
|
||||
-[ RECORD 3 ]-+------------------------------
|
||||
schema_public | badges
|
||||
-[ RECORD 4 ]-+------------------------------
|
||||
schema_public | email_templates
|
||||
-[ RECORD 5 ]-+------------------------------
|
||||
schema_public | geocoders
|
||||
-[ RECORD 6 ]-+------------------------------
|
||||
schema_public | iso3166
|
||||
-[ RECORD 7 ]-+------------------------------
|
||||
schema_public | mid
|
||||
-[ RECORD 8 ]-+------------------------------
|
||||
schema_public | ne_10m_geography_marine_polys
|
||||
-[ RECORD 9 ]-+------------------------------
|
||||
schema_public | process_queue
|
||||
-[ RECORD 10 ]+------------------------------
|
||||
schema_public | spatial_ref_sys
|
||||
|
||||
-[ RECORD 1 ]---------
|
||||
schema_auth | accounts
|
||||
-[ RECORD 2 ]---------
|
||||
schema_auth | otp
|
||||
-[ RECORD 3 ]---------
|
||||
schema_auth | vessels
|
||||
|
||||
(0 rows)
|
||||
|
||||
List Row Security Policies
|
||||
-[ RECORD 1 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metadata
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 2 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metadata
|
||||
policyname | api_vessel_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {vessel_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | true
|
||||
-[ RECORD 3 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metadata
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, true))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 4 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metadata
|
||||
policyname | api_scheduler_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {scheduler}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 5 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metadata
|
||||
policyname | grafana_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | false
|
||||
-[ RECORD 6 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metadata
|
||||
policyname | grafana_proxy_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana_auth}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | false
|
||||
-[ RECORD 7 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metrics
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 8 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metrics
|
||||
policyname | api_vessel_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {vessel_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | true
|
||||
-[ RECORD 9 ]------------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | moorages
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 10 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metrics
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, true))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 11 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metrics
|
||||
policyname | api_scheduler_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {scheduler}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 12 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | metrics
|
||||
policyname | grafana_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | false
|
||||
-[ RECORD 13 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | logbook
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 14 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | logbook
|
||||
policyname | api_vessel_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {vessel_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | true
|
||||
-[ RECORD 15 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | logbook
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, true))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 16 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | vessels
|
||||
policyname | grafana_proxy_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana_auth}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | false
|
||||
-[ RECORD 17 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | accounts
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 18 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | logbook
|
||||
policyname | api_scheduler_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {scheduler}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 19 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | logbook
|
||||
policyname | grafana_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | false
|
||||
-[ RECORD 20 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | stays
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 21 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | stays
|
||||
policyname | api_vessel_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {vessel_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | true
|
||||
-[ RECORD 22 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | stays
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, true))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 23 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | stays
|
||||
policyname | api_scheduler_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {scheduler}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 24 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | stays
|
||||
policyname | grafana_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | false
|
||||
-[ RECORD 25 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | moorages
|
||||
policyname | api_vessel_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {vessel_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | true
|
||||
-[ RECORD 26 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | moorages
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, true))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 27 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | moorages
|
||||
policyname | api_scheduler_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {scheduler}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
-[ RECORD 28 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | api
|
||||
tablename | moorages
|
||||
policyname | grafana_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana}
|
||||
cmd | ALL
|
||||
qual | (vessel_id = current_setting('vessel.id'::text, false))
|
||||
with_check | false
|
||||
-[ RECORD 29 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | vessels
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 30 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | vessels
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | ((vessel_id = current_setting('vessel.id'::text, true)) AND ((owner_email)::text = current_setting('user.email'::text, true)))
|
||||
with_check | ((vessel_id = current_setting('vessel.id'::text, true)) AND ((owner_email)::text = current_setting('user.email'::text, true)))
|
||||
-[ RECORD 31 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | vessels
|
||||
policyname | grafana_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana}
|
||||
cmd | ALL
|
||||
qual | ((owner_email)::text = current_setting('user.email'::text, true))
|
||||
with_check | false
|
||||
-[ RECORD 32 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | accounts
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | ((email)::text = current_setting('user.email'::text, true))
|
||||
with_check | ((email)::text = current_setting('user.email'::text, true))
|
||||
-[ RECORD 33 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | accounts
|
||||
policyname | api_scheduler_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {scheduler}
|
||||
cmd | ALL
|
||||
qual | ((email)::text = current_setting('user.email'::text, true))
|
||||
with_check | ((email)::text = current_setting('user.email'::text, true))
|
||||
-[ RECORD 34 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | auth
|
||||
tablename | accounts
|
||||
policyname | grafana_proxy_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {grafana_auth}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | false
|
||||
-[ RECORD 35 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | public
|
||||
tablename | process_queue
|
||||
policyname | admin_all
|
||||
permissive | PERMISSIVE
|
||||
roles | {username}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | true
|
||||
-[ RECORD 36 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | public
|
||||
tablename | process_queue
|
||||
policyname | api_vessel_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {vessel_role}
|
||||
cmd | ALL
|
||||
qual | ((ref_id = current_setting('user.id'::text, true)) OR (ref_id = current_setting('vessel.id'::text, true)))
|
||||
with_check | true
|
||||
-[ RECORD 37 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | public
|
||||
tablename | process_queue
|
||||
policyname | api_user_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {user_role}
|
||||
cmd | ALL
|
||||
qual | ((ref_id = current_setting('user.id'::text, true)) OR (ref_id = current_setting('vessel.id'::text, true)))
|
||||
with_check | ((ref_id = current_setting('user.id'::text, true)) OR (ref_id = current_setting('vessel.id'::text, true)))
|
||||
-[ RECORD 38 ]-----------------------------------------------------------------------------------------------------------------------------
|
||||
schemaname | public
|
||||
tablename | process_queue
|
||||
policyname | api_scheduler_role
|
||||
permissive | PERMISSIVE
|
||||
roles | {scheduler}
|
||||
cmd | ALL
|
||||
qual | true
|
||||
with_check | false
|
||||
|
||||
Test nominatim reverse_geocode_py_fn
|
||||
-[ RECORD 1 ]---------+-------
|
||||
reverse_geocode_py_fn | España
|
||||
|
||||
Test geoip reverse_geoip_py_fn
|
||||
-[ RECORD 1 ]----------------------------------------------------------------------------------------------------------------------------------------------
|
||||
versions_fn | {"api_version" : "0.2.3", "sys_version" : "PostgreSQL 15.4", "timescaledb" : "2.11.2", "postgis" : "3.4.0", "postgrest" : "PostgREST 11.2.0"}
|
||||
|
||||
-[ RECORD 1 ]-----------------
|
||||
api_version | 0.2.3
|
||||
sys_version | PostgreSQL 15.4
|
||||
timescaledb | 2.11.2
|
||||
postgis | 3.4.0
|
||||
postgrest | PostgREST 11.2.0
|
||||
|
48
tests/sql/telegram.sql
Normal file
48
tests/sql/telegram.sql
Normal file
@@ -0,0 +1,48 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
--
|
||||
-- telegram
|
||||
SET ROLE username;
|
||||
-- Does chat id session exist?
|
||||
SELECT auth.telegram_session_exists_fn(1234567890);
|
||||
SELECT auth.telegram_session_exists_fn(9876543210);
|
||||
SELECT auth.telegram_session_exists_fn(1472583690);
|
||||
|
||||
-- Assign vessel_id var
|
||||
SELECT v.vessel_id as "vessel_id_kapla" FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud' \gset
|
||||
SELECT v.vessel_id as "vessel_id_aava" FROM auth.vessels v WHERE v.owner_email = 'demo+aava@openplotter.cloud' \gset
|
||||
|
||||
SET ROLE api_anonymous;
|
||||
SELECT api.telegram(1234567890::BIGINT) IS NOT NULL as telegram_session;
|
||||
SELECT api.telegram(9876543210::BIGINT) IS NOT NULL as telegram_session;
|
||||
SELECT api.telegram(1472583690::BIGINT) IS NULL as telegram_session;
|
||||
|
||||
SET ROLE user_role;
|
||||
SET "user.email" = 'demo+kapla@openplotter.cloud';
|
||||
--SET vessel.id = 'f94e995cf4d3';
|
||||
SELECT set_config('vessel.id', :'vessel_id_kapla', false) IS NOT NULL as vessel_id;
|
||||
SET vessel.name = 'kapla';
|
||||
--SET vessel.client_id = 'vessels.urn:mrn:imo:mmsi:123456789';
|
||||
--SELECT * FROM api.vessels_view v;
|
||||
SELECT name, mmsi, created_at IS NOT NULL as created_at, last_contact IS NOT NULL as last_contact FROM api.vessels_view v;
|
||||
SELECT name,geojson,watertemperature,insidetemperature,outsidetemperature FROM api.monitoring_view m;
|
||||
|
||||
SET "user.email" = 'demo+aava@openplotter.cloud';
|
||||
SELECT set_config('vessel.id', :'vessel_id_aava', false) IS NOT NULL as vessel_id;
|
||||
--SET vessel.id = '341dcfa30afb';
|
||||
SET vessel.name = 'aava';
|
||||
--SET vessel.client_id = 'vessels.urn:mrn:imo:mmsi:787654321';
|
||||
--SELECT * FROM api.vessels_view v;
|
||||
SELECT name, mmsi, created_at IS NOT NULL as created_at, last_contact IS NOT NULL as last_contact FROM api.vessels_view v;
|
||||
SELECT name,geojson,watertemperature,insidetemperature,outsidetemperature FROM api.monitoring_view m;
|
64
tests/sql/telegram.sql.output
Normal file
64
tests/sql/telegram.sql.output
Normal file
@@ -0,0 +1,64 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
SET
|
||||
-[ RECORD 1 ]--------------+--
|
||||
telegram_session_exists_fn | f
|
||||
|
||||
-[ RECORD 1 ]--------------+--
|
||||
telegram_session_exists_fn | f
|
||||
|
||||
-[ RECORD 1 ]--------------+--
|
||||
telegram_session_exists_fn | f
|
||||
|
||||
SET
|
||||
-[ RECORD 1 ]----+--
|
||||
telegram_session | f
|
||||
|
||||
-[ RECORD 1 ]----+--
|
||||
telegram_session | f
|
||||
|
||||
-[ RECORD 1 ]----+--
|
||||
telegram_session | t
|
||||
|
||||
SET
|
||||
SET
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
SET
|
||||
-[ RECORD 1 ]+------
|
||||
name | kapla
|
||||
mmsi |
|
||||
created_at | t
|
||||
last_contact | t
|
||||
|
||||
-[ RECORD 1 ]------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
name | kapla
|
||||
geojson | {"type": "Feature", "geometry": {"type": "Point", "coordinates": [23.365766667, 59.86]}, "properties": {"name": "kapla", "latitude": 59.86, "longitude": 23.365766666666666}}
|
||||
watertemperature |
|
||||
insidetemperature |
|
||||
outsidetemperature |
|
||||
|
||||
SET
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
SET
|
||||
-[ RECORD 1 ]+----------
|
||||
name | aava
|
||||
mmsi | 787654321
|
||||
created_at | t
|
||||
last_contact | t
|
||||
|
||||
-[ RECORD 1 ]------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
name | aava
|
||||
geojson | {"type": "Feature", "geometry": {"type": "Point", "coordinates": [2.2934791, 41.465333283]}, "properties": {"name": "aava", "latitude": 41.46533328333334, "longitude": 2.2934791}}
|
||||
watertemperature | 280.25
|
||||
insidetemperature |
|
||||
outsidetemperature |
|
||||
|
Reference in New Issue
Block a user