From dc784b399d3f449dc7329e18449567d5cf9b13fb Mon Sep 17 00:00:00 2001 From: Niklas Sombert Date: Fri, 20 Oct 2023 19:03:35 +0200 Subject: [PATCH] :bug: Fix caffeine calculation (closes #143) --- app/controllers/wrapped_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wrapped_controller.rb b/app/controllers/wrapped_controller.rb index 7cd97209..d6a572d1 100644 --- a/app/controllers/wrapped_controller.rb +++ b/app/controllers/wrapped_controller.rb @@ -40,7 +40,7 @@ def most_bought_drink(audits, year) end def caffeine(audits) - total = audits.joins(:drink).sum(:caffeine) + total = audits.joins(:drink).sum("caffeine * (bottle_size / 0.1)") if total.positive? # for humans: overdose: 1000 mg, intoxication: 5000 mg would_kill_kg = total / 192.0 # lethal dosage (mg) per kg