207 h.humulene = obj["h_humulene"].toDouble(); |
207 h.humulene = obj["h_humulene"].toDouble(); |
208 h.caryophyllene = obj["h_caryophyllene"].toDouble(); |
208 h.caryophyllene = obj["h_caryophyllene"].toDouble(); |
209 h.cohumulone = obj["h_cohumulone"].toDouble(); |
209 h.cohumulone = obj["h_cohumulone"].toDouble(); |
210 h.myrcene = obj["h_myrcene"].toDouble(); |
210 h.myrcene = obj["h_myrcene"].toDouble(); |
211 h.total_oil = obj["h_total_oil"].toDouble(); |
211 h.total_oil = obj["h_total_oil"].toDouble(); |
|
212 h.utilisation = obj["h_utilisation"].toDouble(); |
|
213 h.bu_factor = obj["h_bu_factor"].toDouble(); |
|
214 /* Update */ |
|
215 if (h.utilisation == 0 || h.bu_factor == 0) { |
|
216 yquery.prepare("SELECT utilisation,bu_factor FROM inventory_hops WHERE name=:name AND origin=:origin"); |
|
217 yquery.bindValue(":name", h.name); |
|
218 yquery.bindValue(":origin", h.origin); |
|
219 yquery.exec(); |
|
220 if (yquery.first()) { |
|
221 h.utilisation = yquery.value("utilisation").toDouble(); |
|
222 h.bu_factor = yquery.value("bu_factor").toDouble(); |
|
223 } |
|
224 } |
212 reci->hops.append(h); |
225 reci->hops.append(h); |
213 } |
226 } |
214 } |
227 } |
215 } else { |
228 } else { |
216 qDebug() << "empty hops"; |
229 qDebug() << "empty hops"; |
534 obj.insert("h_humulene", round(reci->hops.at(i).humulene * 100) / 100); |
547 obj.insert("h_humulene", round(reci->hops.at(i).humulene * 100) / 100); |
535 obj.insert("h_caryophyllene", round(reci->hops.at(i).caryophyllene * 100) / 100); |
548 obj.insert("h_caryophyllene", round(reci->hops.at(i).caryophyllene * 100) / 100); |
536 obj.insert("h_cohumulone", round(reci->hops.at(i).cohumulone * 100) / 100); |
549 obj.insert("h_cohumulone", round(reci->hops.at(i).cohumulone * 100) / 100); |
537 obj.insert("h_myrcene", round(reci->hops.at(i).myrcene * 100) / 100); |
550 obj.insert("h_myrcene", round(reci->hops.at(i).myrcene * 100) / 100); |
538 obj.insert("h_total_oil", round(reci->hops.at(i).total_oil * 100) / 100); |
551 obj.insert("h_total_oil", round(reci->hops.at(i).total_oil * 100) / 100); |
|
552 obj.insert("h_utilisation", round(reci->hops.at(i).utilisation * 100) / 100); |
|
553 obj.insert("h_bu_factor", round(reci->hops.at(i).bu_factor * 100) / 100); |
539 array.append(obj); /* Append this object */ |
554 array.append(obj); /* Append this object */ |
540 } |
555 } |
541 QJsonDocument doc; |
556 QJsonDocument doc; |
542 doc.setArray(array); |
557 doc.setArray(array); |
543 query.bindValue(":json_hops", doc.toJson(QJsonDocument::Compact)); |
558 query.bindValue(":json_hops", doc.toJson(QJsonDocument::Compact)); |