Skip to content

Commit e33310e

Browse files
authored
remove baazar products
1 parent d1b42c2 commit e33310e

File tree

1 file changed

+1
-32
lines changed

1 file changed

+1
-32
lines changed

functions.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,6 @@
11
const distance = require("jaro-winkler");
22

33
module.exports = {
4-
getBazaarProduct: (query, products) => {
5-
let resultMatch;
6-
let itemResults = [];
7-
for (const key in products) {
8-
itemResults.push({...products[key]});
9-
}
10-
for (const product of itemResults) {
11-
if (product.name.toLowerCase() == query) {
12-
resultMatch = product;
13-
}
14-
product.tagMatches = 0;
15-
product.distance = distance(product.name, query, {caseSensitive: false});
16-
for (const part of query.split(" ")) {
17-
for (const tag of product.tag) {
18-
if (tag == part) {
19-
product.tagMatches++;
20-
}
21-
}
22-
}
23-
}
24-
itemResults = itemResults.sort((a, b) => {
25-
if (a.tagMatches > b.tagMatches) return -1;
26-
if (a.tagMatches < b.tagMatches) return 1;
27-
if (a.distance > b.distance) return -1;
28-
if (a.distance < b.distance) return 1;
29-
});
30-
if (!resultMatch) {
31-
resultMatch = itemResults[0];
32-
}
33-
return resultMatch;
34-
},
354
formatNumber: (number, floor, rounding = 10) => {
365
let roundFunc = floor ? Math.floor : Math.ceil;
376
if (number < 1000) {
@@ -46,4 +15,4 @@ module.exports = {
4615
return (roundFunc(number / 1000 / 1000 / 1000 * rounding * 10) / (rounding * 10)).toFixed(rounding.toString().length) + 'B';
4716
}
4817
}
49-
}
18+
}

0 commit comments

Comments
 (0)