cosmo/backend/scripts/add_event_fetch_job.sql

33 lines
1.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- Add Scheduled Job for Fetching Close Approach Events
-- This uses the predefined task: fetch_close_approach_events
--
-- 参数说明:
-- - days_ahead: 30 (查询未来30天的事件)
-- - dist_max: "30" (30 AU海王星轨道范围)
-- - approach_body: "Earth" (接近地球的天体)
-- - limit: 200 (最多返回200个事件)
-- - clean_old_events: true (清理过期事件)
--
-- Cron表达式: '0 2 * * 0' (每周日UTC 02:00执行)
--
-- 注意: 任务会自动创建不存在的天体记录(小行星/彗星)
INSERT INTO "public"."scheduled_jobs"
("name", "job_type", "predefined_function", "function_params", "cron_expression", "description", "is_active")
VALUES
(
'每周天体事件拉取 (Close Approaches)',
'predefined',
'fetch_close_approach_events',
'{
"days_ahead": 30,
"dist_max": "30",
"approach_body": "Earth",
"limit": 200,
"clean_old_events": true
}'::jsonb,
'0 2 * * 0',
'每周日UTC 02:00从NASA SBDB拉取未来30天内距离地球30AU以内海王星轨道范围的小行星/彗星接近事件',
true
)
ON CONFLICT DO NOTHING;