-- create a new admin user with username awsadmin@agvalnetworks.com  and password yaJK0189MOat55kl
WITH new_user AS (
  INSERT INTO users (id, name, password, email, confirmationPin, isConfirmed, status, createdAt, updatedAt)
  VALUES (gen_random_uuid(), 'Agval AWS Admin', '$2b$12$96E2dQ1utzRSz4m.RluYMOvxffq/Rxx8MM61U1LqWvmhtmWinZhV.', 'awsadmin@agvalnetworks.com', NULL, true, 'verified', NOW(), NOW())
  RETURNING id
)
INSERT INTO user_roles (user_id, role_id)
SELECT new_user.id, roles.id
FROM new_user
CROSS JOIN roles
WHERE roles.name = 'admin';
-- 'admin',, 'user', 'installer', 'viewer', 'uploader', 'downloader', 'editor', 'superviewer'

select id from users;

INSERT INTO stations (
  name,
  station_id,
  location,
  latitude,
  longitude,
  elevation,
  start_date,
  end_date,
  station_status,
  data_sources,
  network_membership,
  contact_person,
  contact_email,
  contact_phone,
  installation_date,
  weather_parameters,
  sensor_specifications,
  sensor_heights,
  data_collection_intervals,
  instrumentation_setup,
  data_transmission_method,
  data_processing_steps,
  calibration_schedule,
  data_access_formats,
  station_history,
  data_quality,
  equipment_calibration,
  maintenance_history,
  data_availability,
  registered_by_user
)
VALUES (
  'Station Name',
  'STATION123',
  'Gaborone, Botswana',
  -24.6541,
  25.9087,
  1000,
  '2023-08-07',
  '2023-12-31',
  'Active',
  '{weather_data_1, weather_data_2}',
  'Network Name',
  'John Doe',
  'john@example.com',
  '123-456-7890',
  '2023-08-07',
  '{"temp": true, "humidity": true, "precipitation": true}',
  '{"air_temperature": true, "precipitation": true, "rel_humidity": true, "windspeed": true, "winddirection_degrees": true, "radiation": true, "air_pressure": true}',
  '["sensor1", "sensor2"]',
  '["0m", "10m"]',
  '["15min", "1hour"]',
  'Setup Description',
  'Wireless',
  'Data processing steps',
  'Calibration schedule',
  'Data access formats',
  'Station history',
  'Data quality description',
  'Equipment calibration description',
  'Maintenance history description',
  'Data availability',
  'b5e096d8-a519-440f-b53f-ba3c1c1d4f78' -- Replace with the actual UUID
);


{
  "station_id": "02391ebf-93c3-48dd-bb41-9d6f75cddd70",
  "timestamp": "2023-08-07T12:34:56",
  "duration": 60,
  "air_temperature": 28.5,
  "precipitation": 0.2,
  "rel_humidity": 60.2,
  "windspeed": 15.3,
  "winddirection_degrees": 180,
  "radiation": 350,
  "air_pressure": 1015.2
}


UPDATE stations
SET weather_parameters = '{"air_temperature": true, "precipitation": true, "rel_humidity": true, "windspeed": true, "winddirection_degrees": true, "radiation": true, "air_pressure": true}'
WHERE station_id = 'STATION123';