--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="/home/dan/ed/satnogs/scheduling-bazaar/data/stations.db" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="2"/><attached/><window><current_tab id="1"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="2936"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="stations"/><default_encoding codec=""/><browse_table_settings><table schema="main" name="stations" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths/><filter_values/><display_formats/><hidden_columns/><plot_y_axes/></table><table schema="main" name="text" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths/><filter_values/><display_formats/><hidden_columns/><plot_y_axes/></table></browse_table_settings></tab_browse><tab_sql><sql name="stations-schema.sql">CREATE TABLE IF NOT EXISTS stations (
+ id PRIMARY KEY,
+ altitude REAL,
+ antenna TEXT CHECK(json_valid(antenna)), -- array of objects
+ client_version TEXT,
+ created TEXT, -- YYYY-mm-ddTHH:MMZ
+ description TEXT,
+ last_seen TEXT, -- YYYY-mm-ddTHH:MMZ
+ lat REAL,
+ lng REAL,
+ min_horizon REAL,
+ name TEXT,
+ observations INT,
+ qthlocator TEXT,
+ status TEXT,
+ target_utilization INT,
+ rotator INT -- 0, 1, or 2 axis rotation
+ );
+
+-- Then, add rows from the stations.json. This was done via CSV import, but it should
+-- be configured to directly ingest from the JSON in order to keep the DB up to date.
+</sql><sql name="SQL 2">-- Translate antenna_type into a presumed number of motion axes
+
+-- turnstile
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "turnstile";
+
+-- yagi
+UPDATE stations SET rotator = 2
+WHERE json_extract(antenna, "$[0].antenna_type") = "yagi";
+
+-- quadrafilar
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "quadrafilar";
+
+-- vertical
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "vertical";
+
+-- cross-yagi
+UPDATE stations SET rotator = 2
+WHERE json_extract(antenna, "$[0].antenna_type") = "cross-yagi";
+
+-- dipole
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "dipole";
+
+-- v-dipole
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "v-dipole";
+
+-- discone
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "discone";
+
+-- eggbeater
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "eggbeater";
+
+-- other omni
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "other omni";
+
+-- helical
+UPDATE stations SET rotator = 2
+WHERE json_extract(antenna, "$[0].antenna_type") = "helical";
+
+-- ground
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "ground";
+
+-- lindenblad
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "lindenblad";
+
+-- other direct
+UPDATE stations SET rotator = 2
+WHERE json_extract(antenna, "$[0].antenna_type") = "other direct";
+
+-- parabolic
+UPDATE stations SET rotator = 2
+WHERE json_extract(antenna, "$[0].antenna_type") = "parabolic";
+
+-- patch
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "patch";
+
+-- paralindy
+UPDATE stations SET rotator = 0
+WHERE json_extract(antenna, "$[0].antenna_type") = "paralindy";
+</sql><sql name="SQL 7">-- Setup for searching name, description fields for various text.
+-- This is to find stations with different rotators than what may
+-- be implied by their declared antenna_type(s)
+CREATE VIRTUAL TABLE IF NOT EXISTS text
+USING FTS5(id, name, description);
+
+INSERT OR REPLACE INTO text
+SELECT id, name, description from stations;
+</sql><sql name="SQL 8">-- Modify the rotator column to better reflect what the description claims
+SELECT DISTINCT
+ text.id,
+ text.name,
+ text.description,
+ stations.antenna,
+ stations.rotator
+FROM text, stations
+WHERE text.id = stations.id
+AND stations.rotator = 2
+AND text MATCH 'fixed'
+ORDER BY text.id;
+
+-- ok, look at the results above and decide which stations have only 0 or 1 axes or motion
+
+UPDATE stations
+SET rotator = 0
+WHERE id IN (66, 212, 1351, 1787, 1810, 1868, 1950, 2080, 2107, 2246, 2263,
+ 2372, 2430, 2501, 2650);
+
+
+-- Find another pattern that implies a rotator
+SELECT DISTINCT
+ text.id,
+ text.name,
+ text.description,
+ stations.antenna,
+ stations.rotator
+FROM text, stations
+WHERE text.id = stations.id
+AND text MATCH '5500'
+AND rotator <> 2
+ORDER BY text.id;
+
+-- There were a couple
+UPDATE stations SET rotator = 2 WHERE id IN (888, 2233);
+
+
+-- Third search
+SELECT DISTINCT
+ text.id,
+ text.name,
+ text.description,
+ stations.antenna,
+ stations.rotator
+FROM text, stations
+WHERE text.id = stations.id
+AND text MATCH 'spid'
+AND rotator <> 2
+ORDER BY text.id;
+
+-- Found another rotator
+UPDATE stations SET rotator = 2 WHERE id IN (2500);
+
+
+-- Fourth search
+SELECT DISTINCT
+ text.id,
+ text.name,
+ text.description,
+ stations.antenna,
+ stations.rotator
+FROM text, stations
+WHERE text.id = stations.id
+AND text MATCH 'azimuth'
+AND rotator <> 5
+ORDER BY text.id;
+
+-- Found more rotators
+UPDATE stations SET rotator = 2 WHERE id IN (357, 1146, 2221);
+
+-- And an azimuth-only station!
+UPDATE stations SET rotator = 1 WHERE id IN (1775);
+
+
+-- Fifth search
+SELECT DISTINCT
+ text.id,
+ text.name,
+ text.description,
+ stations.antenna,
+ stations.rotator
+FROM text, stations
+WHERE text.id = stations.id
+AND text MATCH 'elevation'
+AND rotator <> 5
+ORDER BY text.id;
+
+-- More no-rotator stations
+UPDATE stations SET rotator = 0 WHERE id IN (146, 484, 1640, 1710, 1789, 2029);
+
+-- Now would be a good time to find the stations with directional antennas but no rotator
+</sql><sql name="SQL 5">-- What is remaining?
+SELECT
+ json_extract(antenna, "$[0].antenna_type") as type,
+ count(antenna) as num_type
+FROM stations
+--WHERE rotator NOT IN (0, 1, 2)
+GROUP BY type
+ORDER BY num_type DESC;</sql><sql name="SQL 4">SELECT
+ json_extract(antenna, "$[0].antenna_type") as type,
+ count(antenna) as num_type
+FROM stations
+GROUP BY type
+ORDER BY num_type DESC;</sql><sql name="SQL 9">-- Number of stations by motion axes
+SELECT
+ rotator,
+ count(rotator) as num
+FROM stations
+GROUP BY rotator
+ORDER BY rotator;</sql><sql name="SQL 6">-- How many GS were created
+SELECT
+ 2022 as year,
+ status,
+ count(id) as num_new
+FROM stations
+WHERE strftime("%s", created) < strftime("%s", printf("%d-01-01", year+1))
+ AND strftime("%s", created) >= strftime("%s", printf("%d-01-01", year))
+GROUP BY status
+;</sql><current_tab id="4"/></tab_sql></sqlb_project>