openculinary / frontend

The RecipeRadar Frontend is a recipe search and meal planning application
GNU Affero General Public License v3.0
13 stars 2 forks source link

Shopping list: total quantities are not calculated correctly under some circumstances #159

Closed jayaddison closed 4 years ago

jayaddison commented 4 years ago

Describe the bug Under some circumstances shopping list quantities are currently being calculated correctly.

It's possible that this is a type-casting issue; this is based on an observation that the example recipe below yields 12 servings, and the totals appear to be a multiple of 100x the original quantity => 12 + 12 = 24, but "12+12" = "1212", and 1212 / 12 ~= 100.

To Reproduce Steps to reproduce the behavior:

  1. Visit https://www.reciperadar.com/#search&action=view&id=yiAd1dgx5f3FqJB986SN5fgvqhT5w5s&servings=12
  2. Add the recipe to the meal planner
  3. On the meal planner view, schedule the meal at least twice
  4. Navigate to the shopping list view
  5. Observe that the calculated quantities appear incorrect (that might be too much butter, for example)

image

jayaddison commented 4 years ago

Confirmed by adding a browser development mode breakpoint here: https://github.com/openculinary/frontend/blob/46893aebfec6dea9d1bccf274051f70c06747e8f/src/app/views/shopping-list.js#L112 - the value of servings.scheduled was the string value "01212", and this was being used as the multiplication value.