1
0

Fix migration of default quantities

Allow Quantity formula to be nil but not blank
Add computed energy quantity
Reverse default quantities deletion order
This commit is contained in:
cryptogopher
2019-11-15 00:04:34 +01:00
parent 0e5a53b4b9
commit 3ce5d5c940
4 changed files with 134 additions and 125 deletions

View File

@@ -7,7 +7,7 @@ module BodyTracking
class InvalidFormula < RuntimeError; end
class Formula
def initialize(project, formula)
@project = project
@project_quantities = Quantity.where(project: project)
@formula = formula
@paramed_formula = nil
@quantities = nil
@@ -79,7 +79,7 @@ module BodyTracking
# 4th: check if identifiers used in formula correspond to existing quantities
identifiers.uniq!
quantities = @project.quantities.where(name: identifiers)
quantities = @project_quantities.where(name: identifiers)
quantities_names = quantities.pluck(:name)
(identifiers - quantities_names).each do |q|
errors << [:unknown_quantity, {quantity: q}]