diff --git a/lib/towerops_web/controllers/api/v1/geoip_controller.ex b/lib/towerops_web/controllers/api/v1/geoip_controller.ex index 98ef9201..a7e00c57 100644 --- a/lib/towerops_web/controllers/api/v1/geoip_controller.ex +++ b/lib/towerops_web/controllers/api/v1/geoip_controller.ex @@ -113,7 +113,13 @@ defmodule ToweropsWeb.Api.V1.GeoipController do } end) - {inserted, _} = Repo.insert_all(Location, entries) + # Use upsert to avoid duplicates - replace existing records with same geoname_id + {inserted, _} = + Repo.insert_all(Location, entries, + on_conflict: {:replace_all_except, [:inserted_at]}, + conflict_target: :geoname_id + ) + {:ok, inserted} rescue e -> @@ -144,7 +150,13 @@ defmodule ToweropsWeb.Api.V1.GeoipController do } end) - {inserted, _} = Repo.insert_all(Block, entries) + # Use upsert to avoid duplicates - replace existing records with same network + {inserted, _} = + Repo.insert_all(Block, entries, + on_conflict: {:replace_all_except, [:id, :inserted_at]}, + conflict_target: :network + ) + {:ok, inserted} rescue e -> diff --git a/priv/repo/migrations/20260128193436_add_unique_constraint_to_geoip_blocks.exs b/priv/repo/migrations/20260128193436_add_unique_constraint_to_geoip_blocks.exs new file mode 100644 index 00000000..f65a77a8 --- /dev/null +++ b/priv/repo/migrations/20260128193436_add_unique_constraint_to_geoip_blocks.exs @@ -0,0 +1,8 @@ +defmodule Towerops.Repo.Migrations.AddUniqueConstraintToGeoipBlocks do + use Ecto.Migration + + def change do + # Add unique index on network field to prevent duplicate CIDR blocks + create unique_index(:geoip_blocks, [:network]) + end +end diff --git a/vendor/oban_web/lib/oban/web/components/icons.ex b/vendor/oban_web/lib/oban/web/components/icons.ex index 24d04234..3f263906 100644 --- a/vendor/oban_web/lib/oban/web/components/icons.ex +++ b/vendor/oban_web/lib/oban/web/components/icons.ex @@ -3,24 +3,6 @@ defmodule Oban.Web.Components.Icons do # Helpers - attr :rest, :global, - default: %{ - "aria-hidden": "true", - class: "w-4 h-4", - fill: "currentColor", - viewBox: "0 0 16 16" - } - - slot :inner_block, required: true - - defp svg_mini(assigns) do - ~H""" - - {render_slot(@inner_block)} - - """ - end - attr :rest, :global, default: %{ "stroke-width": "1.5",