1
0

Fixed filtering

This commit is contained in:
cryptogopher 2019-11-10 23:23:59 +01:00
parent 60cfd17c0f
commit 13703dc8ed
2 changed files with 2 additions and 3 deletions

View File

@ -37,7 +37,7 @@ class Ingredient < ActiveRecord::Base
end end
end end
def self.filter(project, filters = {}, requested_q = []) def self.filter(project, filters = {}, requested_q = Quantity.none)
ingredients = all ingredients = all
if filters[:name].present? if filters[:name].present?
@ -120,7 +120,7 @@ class Ingredient < ActiveRecord::Base
all_q = nutrients.merge(completed_q) all_q = nutrients.merge(completed_q)
[ [
filter_q ? ingredients.to_a.keep_if { |i| all_q[filter_q.name][i.id] } : ingredients, filter_q ? ingredients.to_a.keep_if { |i| all_q[filter_q.name][i.id][0] } : ingredients,
ingredients.map { |i| requested_q.map { |q| [q.name, all_q[q.name][i.id]] } }, ingredients.map { |i| requested_q.map { |q| [q.name, all_q[q.name][i.id]] } },
ingredients.map do |i| ingredients.map do |i|
extra_q.map { |q_name| [q_name, all_q[q_name][i.id]] if all_q[q_name][i.id] } extra_q.map { |q_name| [q_name, all_q[q_name][i.id]] if all_q[q_name][i.id] }

View File

@ -118,7 +118,6 @@ module BodyTracking
identifiers << vname identifiers << vname
when :@int when :@int
else else
byebug
errors << [:disallowed_token, {token: token, ttype: ttype}] errors << [:disallowed_token, {token: token, ttype: ttype}]
end end
end end