mirror of
https://github.com/badlogic/heissepreise.git
synced 2024-06-19 23:18:45 +02:00
Remove old entries for discount only stores. Closes #102
This commit is contained in:
parent
b05702aff5
commit
f2ef75e5c4
|
@ -8,3 +8,4 @@ momentum-cart.json
|
||||||
package-lock.json
|
package-lock.json
|
||||||
site/_templates
|
site/_templates
|
||||||
docs/
|
docs/
|
||||||
|
stores/*.json
|
11
analysis.js
11
analysis.js
|
@ -2,6 +2,7 @@ const fs = require("fs");
|
||||||
const fsAsync = require("fs").promises;
|
const fsAsync = require("fs").promises;
|
||||||
const zlib = require("zlib");
|
const zlib = require("zlib");
|
||||||
const stores = require("./stores");
|
const stores = require("./stores");
|
||||||
|
const model = require("./site/model/stores");
|
||||||
const { promisify } = require("util");
|
const { promisify } = require("util");
|
||||||
|
|
||||||
const STORE_KEYS = Object.keys(stores);
|
const STORE_KEYS = Object.keys(stores);
|
||||||
|
@ -92,9 +93,17 @@ function mergePriceHistory(oldItems, items) {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`${Object.keys(lookup).length} not in latest list.`);
|
console.log(`${Object.keys(lookup).length} not in latest list.`);
|
||||||
|
let removed = {};
|
||||||
for (key of Object.keys(lookup)) {
|
for (key of Object.keys(lookup)) {
|
||||||
items.push(lookup[key]);
|
const item = lookup[key];
|
||||||
|
if (model.stores[item.store]?.removeOld) {
|
||||||
|
removed[item.store] = removed[item.store] ? removed[item.store] + 1 : 1;
|
||||||
|
} else {
|
||||||
|
items.push(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
console.log("Removed items for discount-only stores");
|
||||||
|
console.log(JSON.stringify(removed, null, 2));
|
||||||
|
|
||||||
sortItems(items);
|
sortItems(items);
|
||||||
console.log(`Items: ${items.length}`);
|
console.log(`Items: ${items.length}`);
|
||||||
|
|
|
@ -22,14 +22,14 @@ exports.stores = {
|
||||||
defaultChecked: true,
|
defaultChecked: true,
|
||||||
getUrl: (item) => `https://www.roksh.at/hofer/produkte/${item.url}`,
|
getUrl: (item) => `https://www.roksh.at/hofer/produkte/${item.url}`,
|
||||||
},
|
},
|
||||||
// Disabled as they only give us discounted products.
|
lidl: {
|
||||||
/*lidl: {
|
|
||||||
name: "Lidl",
|
name: "Lidl",
|
||||||
budgetBrands: ["milbona"],
|
budgetBrands: ["milbona"],
|
||||||
color: "pink",
|
color: "pink",
|
||||||
defaultChecked: true,
|
defaultChecked: true,
|
||||||
getUrl: (item) => `https://www.lidl.at${item.url}`,
|
getUrl: (item) => `https://www.lidl.at${item.url}`,
|
||||||
},*/
|
removeOld: true,
|
||||||
|
},
|
||||||
mpreis: {
|
mpreis: {
|
||||||
name: "MPREIS",
|
name: "MPREIS",
|
||||||
budgetBrands: [],
|
budgetBrands: [],
|
||||||
|
@ -57,6 +57,7 @@ exports.stores = {
|
||||||
color: "purple",
|
color: "purple",
|
||||||
defaultChecked: true,
|
defaultChecked: true,
|
||||||
getUrl: (item) => `https://www.penny.at/produkte/${item.id}`,
|
getUrl: (item) => `https://www.penny.at/produkte/${item.id}`,
|
||||||
|
removeOld: true,
|
||||||
},
|
},
|
||||||
dmDe: {
|
dmDe: {
|
||||||
name: "DM DE",
|
name: "DM DE",
|
||||||
|
|
|
@ -76,7 +76,6 @@ exports.fetchData = async function () {
|
||||||
|
|
||||||
exports.initializeCategoryMapping = async () => {
|
exports.initializeCategoryMapping = async () => {
|
||||||
// FIXME check if categories have changed.
|
// FIXME check if categories have changed.
|
||||||
console.log("No mapping for Billa");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.mapCategory = (rawItem) => {
|
exports.mapCategory = (rawItem) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user