- Fix score_pressure crash on nil pressure_mb (coastal HRRR points) - Set 10-min timeout on grid score upsert transaction (was :infinity) - Single DELETE for prune_old_scores instead of N queries in a loop - Remove dead load_hrrr_refractivity that loaded 95k rows into nil map - Pass selected_time to point_detail to skip latest_valid_time sub-query - Batch station existence checks (1 query per path point, not per station) - Batch solar index upserts via insert_all in chunks of 500 - Batch backfill_distances via single UPDATE FROM VALUES statement - Add is_grid_point boolean + partial index to hrrr_profiles (replaces non-sargable modular arithmetic filter on every weather map query) - Add partial index on contacts(qso_timestamp) WHERE pos1 IS NOT NULL - Move backfill enqueue to Oban worker so UI returns immediately
39 lines
1.3 KiB
Elixir
39 lines
1.3 KiB
Elixir
defmodule Microwaveprop.Weather.HrrrProfile do
|
|
@moduledoc false
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
@primary_key {:id, :binary_id, autogenerate: true}
|
|
@foreign_key_type :binary_id
|
|
|
|
schema "hrrr_profiles" do
|
|
field :valid_time, :utc_datetime
|
|
field :lat, :float
|
|
field :lon, :float
|
|
field :run_time, :utc_datetime
|
|
field :profile, {:array, :map}
|
|
field :hpbl_m, :float
|
|
field :pwat_mm, :float
|
|
field :surface_temp_c, :float
|
|
field :surface_dewpoint_c, :float
|
|
field :surface_pressure_mb, :float
|
|
field :surface_refractivity, :float
|
|
field :min_refractivity_gradient, :float
|
|
field :ducting_detected, :boolean, default: false
|
|
field :duct_characteristics, {:array, :map}
|
|
field :is_grid_point, :boolean, default: false
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
@required_fields ~w(valid_time lat lon)a
|
|
@optional_fields ~w(run_time profile hpbl_m pwat_mm surface_temp_c surface_dewpoint_c surface_pressure_mb surface_refractivity min_refractivity_gradient ducting_detected duct_characteristics is_grid_point)a
|
|
|
|
def changeset(hrrr_profile, attrs) do
|
|
hrrr_profile
|
|
|> cast(attrs, @required_fields ++ @optional_fields)
|
|
|> validate_required(@required_fields)
|
|
|> unique_constraint([:lat, :lon, :valid_time])
|
|
end
|
|
end
|