mirror of
https://github.com/badlogic/heissepreise.git
synced 2024-06-04 15:55:30 +02:00
Merge pull request #7 from mhochsteger/fix_unit_spar_items
Fix wrong price/unit pairing in some SPAR items
This commit is contained in:
commit
978354d69e
17
analysis.js
17
analysis.js
|
@ -21,13 +21,24 @@ function sparToCanonical(rawItems, today) {
|
|||
const canonicalItems = [];
|
||||
for (let i = 0; i < rawItems.length; i++) {
|
||||
const item = rawItems[i];
|
||||
|
||||
let price, unit;
|
||||
if (item.masterValues["quantity-selector"]) {
|
||||
const [str_price, str_unit] = item.masterValues["price-per-unit"].split('/');
|
||||
price = parseFloat(str_price.replace("€", ""));
|
||||
unit = str_unit.trim();
|
||||
}
|
||||
else {
|
||||
price = item.masterValues.price;
|
||||
unit = item.masterValues["short-description-3"];
|
||||
}
|
||||
canonicalItems.push({
|
||||
store: "spar",
|
||||
id: item.masterValues["code-internal"],
|
||||
name: item.masterValues.title + " " + item.masterValues["short-description"],
|
||||
price: item.masterValues.price,
|
||||
priceHistory: [{ date: today, price: item.masterValues.price }],
|
||||
unit: item.masterValues["short-description-3"]
|
||||
price,
|
||||
priceHistory: [{ date: today, price }],
|
||||
unit
|
||||
});
|
||||
}
|
||||
return canonicalItems;
|
||||
|
|
Loading…
Reference in New Issue
Block a user