// weatherstories_queries.go contains SQL text for weather story reads.
// Layer: adapters/outbound/postgres weather stories feature.
package postgres

const (
	queryLatestWeatherStoryRun = `
SELECT
  event_id,
  office_id,
  as_of
FROM weather_story_runs
ORDER BY as_of DESC, event_emitted_at DESC
LIMIT 1`

	queryWeatherStoriesForRun = `
SELECT
  story_index,
  office_id,
  start_time,
  end_time,
  updated_at,
  title,
  description,
  alt_text,
  priority,
  story_order,
  download_url
FROM weather_stories
WHERE run_event_id = $1
ORDER BY story_index ASC`

	queryLatestWeatherStory = `
SELECT
  story_index,
  office_id,
  start_time,
  end_time,
  updated_at,
  title,
  description,
  alt_text,
  priority,
  story_order,
  download_url
FROM weather_stories
ORDER BY updated_at DESC, as_of DESC, story_order ASC, story_index ASC
LIMIT 1`
)
