Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stereobooster committed Nov 9, 2023
1 parent 69f1e15 commit 2b7ab78
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
mapValues,
clone as _clone,
map,
chain,
sortBy,
isArray,
orderBy,
Expand Down Expand Up @@ -249,7 +247,7 @@ export const index = function (items, fields) {

let i = 1;

items = map(items, (item) => {
items && items.map((item) => {
if (!item['_id']) {
item['_id'] = i;
++i;
Expand All @@ -258,7 +256,11 @@ export const index = function (items, fields) {
return item;
});

<<<<<<< HEAD
map(items, (item) => {
=======
items && items.map((item) => {
>>>>>>> fb8261d (fix)
fields.forEach((field) => {
//if (!item || !item[field]) {
if (!item) {
Expand Down Expand Up @@ -374,8 +376,7 @@ export const getBuckets = function (data, input, aggregations) {
hide_zero_doc_count = aggregations[k].hide_zero_doc_count || false;
}

let buckets = chain(v)
.toPairs()
let buckets = Object.entries(v)
.map((v2) => {
let filters = [];

Expand All @@ -400,8 +401,7 @@ export const getBuckets = function (data, input, aggregations) {
selected: filters.indexOf(v2[0]) !== -1,
};
})
.compact()
.value();
.filter(Boolean);

let iteratees;
let sort_order;
Expand Down Expand Up @@ -434,21 +434,18 @@ export const getBuckets = function (data, input, aggregations) {

if (show_facet_stats) {
facet_stats = [];
chain(v)
.toPairs()
.forEach((v2) => {
if (isNaN(v2[0])) {
throw new Error('You cant use chars to calculate the facet_stats.');
}
Object.entries(v).forEach((v2) => {
if (isNaN(v2[0])) {
throw new Error('You cant use chars to calculate the facet_stats.');
}

// Doc_count
if (v2[1].array().length > 0) {
v2[1].forEach((/*doc_count*/) => {
facet_stats.push(parseInt(v2[0]));
});
}
})
.value();
// Doc_count
if (v2[1].array().length > 0) {
v2[1].forEach((/*doc_count*/) => {
facet_stats.push(parseInt(v2[0]));
});
}
});

calculated_facet_stats = {
min: minBy(facet_stats),
Expand Down Expand Up @@ -530,11 +527,11 @@ export const input_to_facet_filters = function (input, config) {
export const parse_boolean_query = function (query) {
const result = booleanParser.parseBooleanQuery(query);

return map(result, (v1) => {
return result.map((v1) => {
if (Array.isArray(v1)) {
return map(v1, (v2) => {
return v1.map((v2) => {
if (Array.isArray(v2)) {
return map(v2, (v3) => {
return v2.map((v3) => {
return v3;
});
} else {
Expand Down

0 comments on commit 2b7ab78

Please sign in to comment.