MushroomObserver / mushroom-observer

A website for sharing observations of mushrooms.
https://mushroomobserver.org
MIT License
77 stars 25 forks source link

Observation has_location #2093

Closed JoeCohen closed 3 months ago

JoeCohen commented 3 months ago

Observation pattern search has_location variable is broken. Example: This pattern: Sarcosphaera coronaria region:"Klickitat Co.\, Washington\, USA" has_locations:yes yields http://localhost:3000/observations?pattern=Sarcosphaera+coronaria+region%3A%22Klickitat+Co.%5C%2C+Washington%5C%2C+USA%22+has_location%3Ayes which return 7 Observations, the last 2 of which lack geolocations.

nimmolo commented 3 months ago

@JoeCohen I don't think that parameter checks for lat/lng

# app/classes/query/observation_base.rb
    def initialize_has_location_parameter
      add_boolean_condition(
        "observations.location_id IS NOT NULL",
        "observations.location_id IS NULL",
        params[:has_location]
      )
    end
nimmolo commented 3 months ago

Checking through that file, we don't yet have a search param for "has_lat_long". You could probably write one pretty easily, though.

JoeCohen commented 3 months ago

@nimmolo Thanks for looking at the code ... something I should have done. The in-app documentation says Thanks for checking. That's a surprise to me. The in-app documentation says

has_location: Are the Observation’s Latitude and Longitude fields filled in?

I'm probably the one who misdocumented it.

nimmolo commented 3 months ago

I'm starting a PR to add this search param.

The misunderstanding arises from an inaccurate translation string:

  observation_term_has_location: Are the [:OBSERVATION]'s [:LATITUDE] and [:LONGITUDE] fields filled in?

It should be something like:

  observation_term_has_location: Is the [:OBSERVATION] associated with a defined [:LOCATION]?
nimmolo commented 3 months ago

Whoops, cross posting! Just getting your comment. PR coming...