From fdf116971dc18d8435f8c6b4c417d2211d6c5835 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 22 Mar 2026 13:07:26 -0500 Subject: [PATCH] Allow searching for objects and items by name Updated get_latest_packet_for_callsign to search by sender, object_name, or item_name. This allows users to search for objects like "RADIOWRLD" or "147.06-WC" and have the map center on them, just like searching for a station callsign. For example: - Searching "RADIOWRLD" now finds the GPS Central store object - Searching "147.06-WC" finds the Calgary repeater object - Searching "CALGRY" still finds the Calgary station This makes objects first-class searchable entities on the map. --- lib/aprsme/packets/prepared_queries.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/aprsme/packets/prepared_queries.ex b/lib/aprsme/packets/prepared_queries.ex index 7aa3420..bbff881 100644 --- a/lib/aprsme/packets/prepared_queries.ex +++ b/lib/aprsme/packets/prepared_queries.ex @@ -12,6 +12,7 @@ defmodule Aprsme.Packets.PreparedQueries do @doc """ Get the latest packet for a callsign using a prepared statement. This is one of the most frequently called queries. + Searches by sender, object_name, or item_name. """ @spec get_latest_packet_for_callsign(String.t()) :: Packet.t() | nil def get_latest_packet_for_callsign(callsign) when is_binary(callsign) do @@ -19,7 +20,10 @@ defmodule Aprsme.Packets.PreparedQueries do Repo.one( from(p in Packet, - where: fragment("upper(?)", p.sender) == ^normalized, + where: + fragment("upper(?)", p.sender) == ^normalized or + fragment("upper(?)", p.object_name) == ^normalized or + fragment("upper(?)", p.item_name) == ^normalized, order_by: [desc: p.received_at], limit: 1, select: %{p | lat: fragment("ST_Y(?)", p.location), lon: fragment("ST_X(?)", p.location)}