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.
This commit is contained in:
parent
ad7cdc6ee2
commit
fdf116971d
1 changed files with 5 additions and 1 deletions
|
|
@ -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)}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue