Update cron_process_windy_fn, fix main loop query

This commit is contained in:
xbgmsharp
2024-02-06 13:51:32 +01:00
parent 8dba0c21b6
commit f942076cc2

View File

@@ -419,16 +419,17 @@ BEGIN
-- Check for new observations pending update -- Check for new observations pending update
RAISE NOTICE 'cron_process_windy_fn'; RAISE NOTICE 'cron_process_windy_fn';
-- Gather url from app settings -- Gather url from app settings
app_settings := get_app_settings_fn(); app_settings := get_app_settings_fn();
-- Find users with windy active and with an active vessel -- Find users with windy active and with an active vessel
FOR windy_rec in FOR windy_rec in
SELECT SELECT
a.id,a.user_id,a.email,v.vessel_id,m.name,COALESCE((a.preferences->'windy_last_metric')::TEXT,'2024-01-01') as last_metric a.user_id,a.email,v.vessel_id,
FROM auth.accounts a, auth.vessels v, api.metadata m COALESCE((a.preferences->'windy_last_metric')::TEXT,'2024-01-01') as last_metric
WHERE m.vessel_id = v.vessel_id FROM auth.accounts a
AND a.email = v.owner_email LEFT JOIN auth.vessels AS v ON v.owner_email = a.email
AND (a.preferences->'public_windy')::boolean = True LEFT JOIN api.metadata AS m ON m.vessel_id = v.vessel_id
AND m.active = true WHERE (a.preferences->'public_windy')::boolean = True
AND m.active = True
LOOP LOOP
RAISE NOTICE '-> cron_process_windy_fn for [%]', windy_rec; RAISE NOTICE '-> cron_process_windy_fn for [%]', windy_rec;
PERFORM set_config('vessel.id', windy_rec.vessel_id, false); PERFORM set_config('vessel.id', windy_rec.vessel_id, false);