Refactor seed view path and improve not planted scope for better clarity

This commit is contained in:
Brenda Wallace committed 2026-11-04 07:39:36 +00:00
1 parent 6d41181c06
commit bf6e973bf0
2 files changed
+3 -4

No files matched your search

+2 -3
View File
@@ -12,7 +12,6 @@ module SeedFiltersHelper
# Pass `path` to look at someone else's seeds with the same filters.
def seed_view_path(path: nil, **changes)
kept = request.query_parameters.slice(*SEED_VIEW_PARAMS).merge(changes.stringify_keys).compact
kept.delete('page')
path ||= request.path
kept.empty? ? path : "#{path}?#{kept.to_query}"
end
@@ -23,8 +22,8 @@ module SeedFiltersHelper
end
# The source chips: a label and the params it sets, where nil takes a param
# off. Each kind of filter has its own param, so they combine: bought and
# heirloom, near me and planted. Clicking a chosen chip takes it off again.
# off. Each kind of filter has its own param, so they combine: catalogue
# and heirloom, near me and planted. Clicking a chosen chip takes it off again.
def seed_source_chips
[['All', { from: nil }],
['My own saving', { from: 'own' }],
+1 -1
View File
@@ -127,7 +127,7 @@ class Seed < ApplicationRecord
scope :from_source, ->(kind) { where(source: SOURCES_BY_KIND.fetch(kind)) }
scope :sown_in, ->(months) { where('seeds.sow_months && ARRAY[?]::integer[]', Array(months)) }
scope :planted, -> { where(id: Planting.where.not(parent_seed_id: nil).select(:parent_seed_id)) }
scope :not_planted, -> { where.not(id: Planting.where.not(parent_seed_id: nil).select(:parent_seed_id)) }
scope :not_planted, -> { where.not(id: planted.select(:id)) }
# Seeds of a crop and of its varieties: choosing tomato finds Brandywine
# tomato seeds too.