Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imported recipes are inconsistent and inaccurate #689

Closed
mrmekon opened this issue Dec 8, 2022 · 4 comments
Closed

Imported recipes are inconsistent and inaccurate #689

mrmekon opened this issue Dec 8, 2022 · 4 comments

Comments

@mrmekon
Copy link

mrmekon commented Dec 8, 2022

Brewtarget has inconsistent behavior when importing a recipe that it previously exported. I've observed the mash methods, addition timings, and yeast measurement unit changing on import.

I tested with Brewtarget version 3.0.4 (Arch linux, x86_64, installed from the AUR package).

I created a recipe in Brewtarget (a previous version), exported it to an XML file (with the current version). The original recipe has two sugar additions that are late boil additions.

01_boohoo_original

I then tried three separate things:

  1. Import back into the same Brewtarget install, cloning the recipe.
  2. Import into a fresh Brewtarget install, as the only copy.
  3. Manually change the names of all of the fermentables/hops/yeast (so they aren't in the database), then import into the same fresh Brewtarget install.

Amusingly, all three imports are incorrect, but in different ways!

When importing back into the same install, some (but not all) of the darker malts switch from "mashed" to "steeped". Boil SG drops a bit, accordingly.

02_boohoo_same_install

When importing into a fresh install, even more of the malts switched to "steeped": Both late additions get marked as normal instead, and boil SG skyrockets accordingly.

03_boohoo_fresh_install

And when importing a recipe with all fermentable names changed, all of them are marked as mashed and late additions, and boil SG drops to 1.000 because there are no grains left in the mash...

04_boohoo_new_fermentables

In all three cases, the yeast switched from being measured in volume (125 mL) to mass (125 g).

The XML files I used for testing are attached (with .txt extensions to make github happy).

boohoo_export.txt

boohoo_modified.txt

And, finally, thanks for all of your work on this great application!

@matty0ung
Copy link
Contributor

Thanks for the detailed report. I've started having a look, initially at why the yeast weight ends up as mass. Seems like we correctly read the <AMOUNT_IS_WEIGHT>FALSE</AMOUNT_IS_WEIGHT> line out of the XML file, but the wrong value is ending up in the DB. Will investigate further...

@matty0ung
Copy link
Contributor

OK, I think I found the culprit:

parsedValue.setValue(true);
Should say parsedValue.setValue(false); instead of parsedValue.setValue(true);

Bit of an embarrassing copy-and-paste typo on my part. Will do a patch in the next day or so hopefully.

@matty0ung
Copy link
Contributor

I think we also need a couple of extra lines here:

fermentable.setAmount_kg(npb(PropertyNames::Fermentable::amount_kg).toDouble());

Should additionally say:

   fermentable.setAddAfterBoil(npb(PropertyNames::Fermentable::addAfterBoil).toBool());
   fermentable.setIsMashed(    npb(PropertyNames::Fermentable::isMashed).toBool());

This one is a bit more tedious to explain. It's to do with how we handle the difference between "a variety of hop/fermentable/yeast/etc" and "a use of this variety of hop/fermentable/yeast/etc in a particular recipe". There are long comments in the code about it. The way we do things has various pros and cons, but it can be confusing and we could do a bit more with naming conventions etc in the code to signpost things.

TLDR: I now have it that when you export the recipe after importing it, you get "the same" XML. By "the same" I mean ignoring some rounding tiny errors in long decimal numbers and a slight name tweak of one ingredient. The former at least I think is expected. I'll double-check the latter.

Working on a patch...

matty0ung pushed a commit to matty0ung/brewken that referenced this issue Dec 9, 2022
matty0ung pushed a commit to matty0ung/brewtarget that referenced this issue Dec 9, 2022
mattiasmaahl added a commit that referenced this issue Dec 10, 2022
Fix for #689 plus a few advance bits for BeerJSON
@matty0ung
Copy link
Contributor

Closing now that https://github.com/Brewtarget/brewtarget/releases/tag/v3.0.5 is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants