Update recipe load/save for the new hops fields.

Fri, 29 Jul 2022 13:20:24 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 29 Jul 2022 13:20:24 +0200
changeset 374
74d541ac514c
parent 373
b02aca4e926c
child 375
c21567bfd703

Update recipe load/save for the new hops fields.

src/database/db_recipe.cpp file | annotate | diff | comparison | revisions
--- a/src/database/db_recipe.cpp	Fri Jul 29 13:12:26 2022 +0200
+++ b/src/database/db_recipe.cpp	Fri Jul 29 13:20:24 2022 +0200
@@ -209,6 +209,19 @@
 		h.cohumulone = obj["h_cohumulone"].toDouble();
 		h.myrcene = obj["h_myrcene"].toDouble();
 		h.total_oil = obj["h_total_oil"].toDouble();
+		h.utilisation = obj["h_utilisation"].toDouble();
+		h.bu_factor = obj["h_bu_factor"].toDouble();
+		/* Update */
+		if (h.utilisation == 0 || h.bu_factor == 0) {
+		    yquery.prepare("SELECT utilisation,bu_factor FROM inventory_hops WHERE name=:name AND origin=:origin");
+		    yquery.bindValue(":name", h.name);
+		    yquery.bindValue(":origin", h.origin);
+		    yquery.exec();
+		    if (yquery.first()) {
+			h.utilisation = yquery.value("utilisation").toDouble();
+			h.bu_factor = yquery.value("bu_factor").toDouble();
+		    }
+		}
 		reci->hops.append(h);
 	    }
 	}
@@ -536,6 +549,8 @@
 		obj.insert("h_cohumulone", round(reci->hops.at(i).cohumulone * 100) / 100);
 		obj.insert("h_myrcene", round(reci->hops.at(i).myrcene * 100) / 100);
 		obj.insert("h_total_oil", round(reci->hops.at(i).total_oil * 100) / 100);
+		obj.insert("h_utilisation", round(reci->hops.at(i).utilisation * 100) / 100);
+		obj.insert("h_bu_factor", round(reci->hops.at(i).bu_factor * 100) / 100);
                 array.append(obj);      /* Append this object */
         }
 	QJsonDocument doc;

mercurial