MushroomObserver / mushroom-observer

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

Add a `field_slip` keyword to Observations PatternSearch #2109

Closed nimmolo closed 3 months ago

nimmolo commented 3 months ago

Allows users to type this in the search field and get back the relevant observation:

field_slip:ATEST-0001

mo-nathan commented 3 months ago

`RuntimeError in ObservationsController#index Don't know how to join from observations to field_slips. Extracted source (around line #265): from, to = to, from else raise("Don't know how to join from #{from} to #{to}.") end

      # By default source table column is just "id"; enter both target and

Rails.root: /Users/nathan/src/mushroom-observer

Application Trace | Framework Trace | Full Trace app/classes/query/modules/joining.rb:265:in `calc_join_condition' app/classes/query/modules/sql.rb:123:in `calc_join_conditions' app/classes/query/modules/sql.rb:121:in `block in calc_join_conditions' app/classes/query/modules/sql.rb:121:in `map' app/classes/query/modules/sql.rb:121:in `calc_join_conditions' app/classes/query/modules/sql.rb:74:in `calc_from_clause' app/classes/query/modules/sql.rb:25:in `query' app/classes/query/modules/low_level_queries.rb:35:in `select_values' app/classes/query/modules/high_level_queries.rb:56:in `result_ids' app/classes/query/modules/high_level_queries.rb:36:in `num_results' app/controllers/application_controller.rb:1437:in `set_index_view_ivars' app/controllers/application_controller.rb:1399:in `show_index_setup' app/controllers/application_controller.rb:1375:in `show_index_of_objects' app/controllers/observations_controller/index.rb:189:in `show_selected_observations' app/controllers/observations_controller/index.rb:131:in `render_pattern_search_results' app/controllers/observations_controller/index.rb:117:in `pattern' app/controllers/application_controller.rb:1335:in `block in index' app/controllers/application_controller.rb:1333:in `each' app/controllers/application_controller.rb:1333:in `index' app/controllers/application_controller.rb:226:in `catch_errors_and_log_request_stats'

mo-nathan commented 3 months ago

Working better. This PR should target main now that njw-field-slip-pdfs has merged.

mo-nathan commented 3 months ago

Even after merging in main locally this PR is failing a lot of tests. I haven't dug into why.

nimmolo commented 3 months ago

@mo-nathan — @pellaea spotted the problem.

My query method needed a guard clause so it only gets applied if there IS a field_slip param.

coveralls commented 3 months ago

Coverage Status

coverage: 94.392% (-0.05%) from 94.443% when pulling 1e524c79589d7f7260547056de80144bc6166285 on nimmo-field-slip-stimulus into 2fcde2aa28d7f6c85b121be16498214b5a0811fe on main.