Fixed filtering
This commit is contained in:
parent
60cfd17c0f
commit
13703dc8ed
@ -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] }
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user