1
0

Preliminary support for comparison formula

This commit is contained in:
cryptogopher
2019-11-07 19:55:16 +01:00
parent 2a3e7e8d00
commit 78cf471ecd
2 changed files with 21 additions and 4 deletions

View File

@@ -223,12 +223,21 @@ class IngredientsController < ApplicationController
def filter_ingredients
filters = session[:filters] || {}
ingredients = @project.ingredients
if filters[:name].present?
ingredients = ingredients.where("name LIKE ?", "%#{filters[:name]}%")
end
if filters[:visibility].present?
ingredients = ingredients.where(hidden: filters[:visibility] == "1" ? false : true)
end
if filters[:nutrients].present?
formula = Formula.new(self.project, filters[:nutrients], comparison: true)
if formula.valid?
end
end
ingredients
end
end