Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

fix(results): remove lodash looping over objects #648

Merged
merged 23 commits into from
Apr 11, 2019

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Mar 22, 2019

Closes #639

This was a quite complicated effort, because most iterations could be of either type.

Migrations done:

  • remove lodash.map
  • remove lodash.get (just a small side effect)
  • remove map / reduce / trim / pickBy in generateHierarchicalTree
  • add some more typing via jsDoc (typescript reads it), but not everywhere
  • went through every usage for every lodash function in SearchResults
  • did some small moves here and there to remove a function's usage fully

This fixes a bug when a facet value can be length, causing lodash to interpret it as an array

@Haroenv Haroenv requested a review from a team March 25, 2019 15:37
Copy link
Member

@francoischalifour francoischalifour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice effort!

We could have used this pass to rename the parameters in the modified higher-order functions (e.g. ffilter).

src/SearchResults/index.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Show resolved Hide resolved
src/SearchResults/index.js Show resolved Hide resolved
@Haroenv
Copy link
Contributor Author

Haroenv commented Mar 26, 2019

From reading

this.facets = [];
var disjunctiveFacets = state.getRefinedDisjunctiveFacets();
var facetsIndices = getIndices(state.facets);
var disjunctiveFacetsIndices = getIndices(state.disjunctiveFacets);
var nextDisjunctiveResult = 1;
var self = this;
// Since we send request only for disjunctive facets that have been refined,
// we get the facets information from the first, general, response.
var mainFacets = mainSubResponse.facets || {};
Object.keys(mainFacets).forEach(function(facetKey) {
var facetValueObject = mainFacets[facetKey];
var hierarchicalFacet = findMatchingHierarchicalFacetFromAttributeName(
state.hierarchicalFacets,
facetKey
);
if (hierarchicalFacet) {
// Place the hierarchicalFacet data at the correct index depending on
// the attributes order that was defined at the helper initialization
var facetIndex = hierarchicalFacet.attributes.indexOf(facetKey);
var idxAttributeName = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});
self.hierarchicalFacets[idxAttributeName][facetIndex] = {
attribute: facetKey,
data: facetValueObject,
exhaustive: mainSubResponse.exhaustiveFacetsCount
};
} else {
var isFacetDisjunctive = state.disjunctiveFacets.indexOf(facetKey) !== -1;
var isFacetConjunctive = state.facets.indexOf(facetKey) !== -1;
var position;
if (isFacetDisjunctive) {
position = disjunctiveFacetsIndices[facetKey];
self.disjunctiveFacets[position] = {
name: facetKey,
data: facetValueObject,
exhaustive: mainSubResponse.exhaustiveFacetsCount
};
assignFacetStats(self.disjunctiveFacets[position], mainSubResponse.facets_stats, facetKey);
}
if (isFacetConjunctive) {
position = facetsIndices[facetKey];
self.facets[position] = {
name: facetKey,
data: facetValueObject,
exhaustive: mainSubResponse.exhaustiveFacetsCount
};
assignFacetStats(self.facets[position], mainSubResponse.facets_stats, facetKey);
}
}
});
// Make sure we do not keep holes within the hierarchical facets
this.hierarchicalFacets = compact(this.hierarchicalFacets);
// aggregate the refined disjunctive facets
disjunctiveFacets.forEach(function(disjunctiveFacet) {
var result = results[nextDisjunctiveResult];
var hierarchicalFacet = state.getHierarchicalFacetByName(disjunctiveFacet);
// There should be only item in facets.
Object.keys(result.facets).forEach(function(dfacet) {
var facetResults = result.facets[dfacet];
var position;
if (hierarchicalFacet) {
position = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});
var attributeIndex = findIndex(self.hierarchicalFacets[position], {attribute: dfacet});
// previous refinements and no results so not able to find it
if (attributeIndex === -1) {
return;
}
self.hierarchicalFacets[position][attributeIndex].data = merge(
{},
self.hierarchicalFacets[position][attributeIndex].data,
facetResults
);
} else {
position = disjunctiveFacetsIndices[dfacet];
var dataFromMainRequest = mainSubResponse.facets && mainSubResponse.facets[dfacet] || {};
self.disjunctiveFacets[position] = {
name: dfacet,
data: defaults({}, facetResults, dataFromMainRequest),
exhaustive: result.exhaustiveFacetsCount
};
assignFacetStats(self.disjunctiveFacets[position], result.facets_stats, dfacet);
if (state.disjunctiveFacetsRefinements[dfacet]) {
state.disjunctiveFacetsRefinements[dfacet].forEach(function(refinementValue) {
// add the disjunctive refinements if it is no more retrieved
if (!self.disjunctiveFacets[position].data[refinementValue] &&
state.disjunctiveFacetsRefinements[dfacet].indexOf(refinementValue) > -1) {
self.disjunctiveFacets[position].data[refinementValue] = 0;
}
});
}
}
});
nextDisjunctiveResult++;
});
// if we have some root level values for hierarchical facets, merge them
state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {
var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
var currentRefinement = state.getHierarchicalRefinement(refinedFacet);
// if we are already at a root refinement (or no refinement at all), there is no
// root level values request
if (currentRefinement.length === 0 || currentRefinement[0].split(separator).length < 2) {
return;
}
var result = results[nextDisjunctiveResult];
Object.keys(result.facets).forEach(function(dfacet) {
var facetResults = result.facets[dfacet];
var position = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});
var attributeIndex = findIndex(self.hierarchicalFacets[position], {attribute: dfacet});
// previous refinements and no results so not able to find it
if (attributeIndex === -1) {
return;
}
// when we always get root levels, if the hits refinement is `beers > IPA` (count: 5),
// then the disjunctive values will be `beers` (count: 100),
// but we do not want to display
// | beers (100)
// > IPA (5)
// We want
// | beers (5)
// > IPA (5)
var defaultData = {};
if (currentRefinement.length > 0) {
var root = currentRefinement[0].split(separator)[0];
defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];
}
self.hierarchicalFacets[position][attributeIndex].data = defaults(
defaultData,
facetResults,
self.hierarchicalFacets[position][attributeIndex].data
);
});
nextDisjunctiveResult++;
});
// add the excludes
Object.keys(state.facetsExcludes).forEach(function(facetName) {
var excludes = state.facetsExcludes[facetName];
var position = facetsIndices[facetName];
self.facets[position] = {
name: facetName,
data: mainSubResponse.facets[facetName],
exhaustive: mainSubResponse.exhaustiveFacetsCount
};
excludes.forEach(function(facetValue) {
self.facets[position] = self.facets[position] || {name: facetName};
self.facets[position].data = self.facets[position].data || {};
self.facets[position].data[facetValue] = 0;
});
});
, it's always available

@Haroenv Haroenv requested review from francoischalifour and a team March 27, 2019 15:33
src/SearchResults/index.js Outdated Show resolved Hide resolved
@Haroenv
Copy link
Contributor Author

Haroenv commented Mar 28, 2019

removing lodash.includes brought it from 35.2 → 35 kB

src/SearchResults/generate-hierarchical-tree.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Show resolved Hide resolved
test/spec/SearchResults/getRefinements.js Show resolved Hide resolved
@Haroenv Haroenv requested a review from samouss April 1, 2019 11:30
src/SearchResults/index.js Outdated Show resolved Hide resolved
src/SearchResults/index.js Outdated Show resolved Hide resolved
Haroenv and others added 3 commits April 11, 2019 15:52
* Revert "Revert "fixes on hierarchical""

This reverts commit abfea91.

* Revert "undo hierarchical changes"

This reverts commit a50a8ae.

* Revert "chore: undo more fixes"

This reverts commit 78d06c2.

* Revert "chore: remove dumb comment lol"

This reverts commit 8054352.

* feedback from review
@Haroenv Haroenv merged commit c1f540f into develop Apr 11, 2019
@Haroenv Haroenv deleted the feat/remove-lodashism branch April 11, 2019 15:23
Haroenv added a commit that referenced this pull request Apr 12, 2019
 * chore(deps): update dependency algolia-frontend-components to v0.0.35 (#605) 41043af
 * chore(deps): update dependency algoliasearch to v3.32.0 (#628) e5cab52
 * chore(deps): update dependency babel-core to v6.26.3 (#581) 051075c
 * chore(deps): update dependency browserify to v14.5.0 (#582) 66e2a79
 * chore(deps): update dependency handlebars to v4.1.0 (#589) bf1c493
 * chore(deps): update dependency http-server to v0.11.1 (#590) 673ee5f
 * chore(deps): update dependency mversion to v1.13.0 (#630) 1304f19
 * chore(deps): update dependency rimraf to v2.6.3 (#596) 5e17830
 * chore: use only yarn (no more npm 👩‍🚒) (#637) dba85a0
 * chore(deps): update st (#625) 5d7d915
 * chore(docs): change jade to pug (#615) 80a20dc, closes #613
 * chore(docs): fix interpolation dd888f2
 * chore(docs): remove folder in  (#616) 7bfc971
 * docs(init): use toggleFacetRefinement instead (#622) 2461ffe
 * docs(instantiate): use existing signature of toggleRefine (#621) 6be5ec1
 * docs: fix InstantSearch link (#640) 2c97a71, closes #640
 * docs: fix typo on hierarchical facets (#646) ee5b3b4, closes #646
 * feat(sffv): throw an error if it's called and the client doesn't have the functions (#623) dd61360
 * fix(results): remove lodash looping over objects (#648) c1f540f, closes #258
 * fix(ua): change the User-Agent to use the new specs lib (version) (#647) eafd4cf
 * refactor(events): replace util.inherits by inline (#653) 16459ae
 * test(client): update index name (#619) 3564274
 * Update README.md ace477e
Haroenv added a commit that referenced this pull request May 7, 2019
 * chore(deps): update dependency algolia-frontend-components to v0.0.35 (#605) 41043af
 * chore(deps): update dependency algoliasearch to v3.32.0 (#628) e5cab52
 * chore(deps): update dependency babel-core to v6.26.3 (#581) 051075c
 * chore(deps): update dependency browserify to v14.5.0 (#582) 66e2a79
 * chore(deps): update dependency handlebars to v4.1.0 (#589) bf1c493
 * chore(deps): update dependency http-server to v0.11.1 (#590) 673ee5f
 * chore(deps): update dependency mversion to v1.13.0 (#630) 1304f19
 * chore(deps): update dependency rimraf to v2.6.3 (#596) 5e17830
 * chore: use only yarn (no more npm 👩‍🚒) (#637) dba85a0
 * chore(deps): update st (#625) 5d7d915
 * chore(docs): change jade to pug (#615) 80a20dc, closes #613
 * chore(docs): fix interpolation dd888f2
 * chore(docs): remove folder in  (#616) 7bfc971
 * docs(init): use toggleFacetRefinement instead (#622) 2461ffe
 * docs(instantiate): use existing signature of toggleRefine (#621) 6be5ec1
 * docs: fix InstantSearch link (#640) 2c97a71, closes #640
 * docs: fix typo on hierarchical facets (#646) ee5b3b4, closes #646
 * feat(sffv): throw an error if it's called and the client doesn't have the functions (#623) dd61360
 * fix(results): remove lodash looping over objects (#648) c1f540f, closes #258
 * fix(ua): change the User-Agent to use the new specs lib (version) (#647) eafd4cf
 * refactor(events): replace util.inherits by inline (#653) 16459ae
 * test(client): update index name (#619) 3564274
 * Update README.md ace477e
Haroenv added a commit that referenced this pull request May 9, 2019
 * chore(deps): update dependency algolia-frontend-components to v0.0.35 (#605) 41043af
 * chore(deps): update dependency algoliasearch to v3.32.0 (#628) e5cab52
 * chore(deps): update dependency babel-core to v6.26.3 (#581) 051075c
 * chore(deps): update dependency browserify to v14.5.0 (#582) 66e2a79
 * chore(deps): update dependency handlebars to v4.1.0 (#589) bf1c493
 * chore(deps): update dependency http-server to v0.11.1 (#590) 673ee5f
 * chore(deps): update dependency mversion to v1.13.0 (#630) 1304f19
 * chore(deps): update dependency rimraf to v2.6.3 (#596) 5e17830
 * chore: use only yarn (no more npm 👩‍🚒) (#637) dba85a0
 * chore(deps): update st (#625) 5d7d915
 * chore(docs): change jade to pug (#615) 80a20dc, closes #613
 * chore(docs): fix interpolation dd888f2
 * chore(docs): remove folder in  (#616) 7bfc971
 * docs(init): use toggleFacetRefinement instead (#622) 2461ffe
 * docs(instantiate): use existing signature of toggleRefine (#621) 6be5ec1
 * docs: fix InstantSearch link (#640) 2c97a71, closes #640
 * docs: fix typo on hierarchical facets (#646) ee5b3b4, closes #646
 * feat(sffv): throw an error if it's called and the client doesn't have the functions (#623) dd61360
 * fix(results): remove lodash looping over objects (#648) c1f540f, closes #258
 * fix(ua): change the User-Agent to use the new specs lib (version) (#647) eafd4cf
 * refactor(events): replace util.inherits by inline (#653) 16459ae
 * test(client): update index name (#619) 3564274
 * Update README.md ace477e
Haroenv added a commit that referenced this pull request May 9, 2019
 * chore(deps): update dependency algolia-frontend-components to v0.0.35 (#605) 41043af
 * chore(deps): update dependency algoliasearch to v3.32.0 (#628) e5cab52
 * chore(deps): update dependency babel-core to v6.26.3 (#581) 051075c
 * chore(deps): update dependency browserify to v14.5.0 (#582) 66e2a79
 * chore(deps): update dependency handlebars to v4.1.0 (#589) bf1c493
 * chore(deps): update dependency http-server to v0.11.1 (#590) 673ee5f
 * chore(deps): update dependency mversion to v1.13.0 (#630) 1304f19
 * chore(deps): update dependency rimraf to v2.6.3 (#596) 5e17830
 * chore: use only yarn (no more npm 👩‍🚒) (#637) dba85a0
 * chore(deps): update st (#625) 5d7d915
 * chore(docs): change jade to pug (#615) 80a20dc, closes #613
 * chore(docs): fix interpolation dd888f2
 * chore(docs): remove folder in  (#616) 7bfc971
 * docs(init): use toggleFacetRefinement instead (#622) 2461ffe
 * docs(instantiate): use existing signature of toggleRefine (#621) 6be5ec1
 * docs: fix InstantSearch link (#640) 2c97a71, closes #640
 * docs: fix typo on hierarchical facets (#646) ee5b3b4, closes #646
 * feat(sffv): throw an error if it's called and the client doesn't have the functions (#623) dd61360
 * fix(results): remove lodash looping over objects (#648) c1f540f, closes #258
 * fix(ua): change the User-Agent to use the new specs lib (version) (#647) eafd4cf
 * refactor(events): replace util.inherits by inline (#653) 16459ae
 * test(client): update index name (#619) 3564274
 * Update README.md ace477e
samouss pushed a commit that referenced this pull request May 9, 2019
* fix(lodash): remove collection methods

done: sumBy, map, find (except one occurence)
todo: includes, orderBy

* fix(getHierarchicalRefinement): deal correctly with no default separator

* finished migration

got rid of lodash/get globally!

* test(results): add test for facet values

* chore(lodash): remove trivial usage of map

* chore(results): remove indexOf

* chore(lodash): migrate filterState

* chore(lodash): remove reduce in formatSort

* test(helper): add failing test case for helper having .length value

* fix(hierarchical): fix "length" bug (and simplify in the meantime)

* chore: fix ran tests

* chore(results): remove lodash.includes

* refactor(lodash): remove isString & indexOf (34.9kB)

* apply feedback from review

* fixes on hierarchical

correct "exhaustive"
fixes #258
keep "path" as name; even if it's a bug

* chore: remove comment

* Revert "fixes on hierarchical"

This reverts commit 042f722.

* undo hierarchical changes

* chore: undo more fixes

* chore: remove dumb comment lol

* feedback from review

* fix(hierarchical): add exhaustive & lodash looping (#651)

* Revert "Revert "fixes on hierarchical""

This reverts commit abfea91.

* Revert "undo hierarchical changes"

This reverts commit a50a8ae.

* Revert "chore: undo more fixes"

This reverts commit 78d06c2.

* Revert "chore: remove dumb comment lol"

This reverts commit 8054352.

* feedback from review

* chore(test): fix integration
Haroenv added a commit that referenced this pull request Nov 18, 2019
* fix(lodash): remove collection methods

done: sumBy, map, find (except one occurence)
todo: includes, orderBy

* fix(getHierarchicalRefinement): deal correctly with no default separator

* finished migration

got rid of lodash/get globally!

* test(results): add test for facet values

* chore(lodash): remove trivial usage of map

* chore(results): remove indexOf

* chore(lodash): migrate filterState

* chore(lodash): remove reduce in formatSort

* test(helper): add failing test case for helper having .length value

* fix(hierarchical): fix "length" bug (and simplify in the meantime)

* chore: fix ran tests

* chore(results): remove lodash.includes

* refactor(lodash): remove isString & indexOf (34.9kB)

* apply feedback from review

* fixes on hierarchical

correct "exhaustive"
fixes #258
keep "path" as name; even if it's a bug

* chore: remove comment

* Revert "fixes on hierarchical"

This reverts commit 042f722.

* undo hierarchical changes

* chore: undo more fixes

* chore: remove dumb comment lol

* feedback from review

* fix(hierarchical): add exhaustive & lodash looping (#651)

* Revert "Revert "fixes on hierarchical""

This reverts commit abfea91.

* Revert "undo hierarchical changes"

This reverts commit a50a8ae.

* Revert "chore: undo more fixes"

This reverts commit 78d06c2.

* Revert "chore: remove dumb comment lol"

This reverts commit 8054352.

* feedback from review

* chore(test): fix integration
Haroenv added a commit that referenced this pull request Nov 18, 2019
 *  fix(merge): change implementation  (#716) 29c2138
 * chore: mention remaining changes f756947
 * chore(deps): update circleci/node:8.15.1 docker digest to ef1a0c4 (#715) f4dab89
 * chore(lodash): remove _.omit (#655) 7db8b4c
 * chore(lodash): remove lodash from dependency list (#705) a63ec6b, closes #552
 * chore(release): allow canary release (#712) 3eb087c
 * chore(removeHierarchicalFacetRefinement): remove error if not refined (#747) e68ecfe
 * chore: merge develop into master (#750) 53c7c62
 * chore: remove Bower support (#711) e7518e2
 * chore(ts): add methods d051f79
 * chore(ts): add ruleContexts to SP 4bdc4a4
 * chore(ts): add searchOnlyWithDerivedHelpers (#739) c6aa31b
 * chore(ts): publish definition file too 1813462
 * chore(TS): isNumericRefined has only one required argument cac8fc3
 * chore(warn): remove unused function (lodash.bind) (#682) c59b7e3
 * chore: update release command 0989880
 * docs: add link to wiki 3598f2a
 * docs: update event signature (#701) bbe4634
 * docs(migration): mention changed methods (#732) f95e680
 * docs(next): add migration guide 8430137
 * docs(serverUsed): mention getRankingInfo (#706) f258c2a, closes #500
 * feat: implement dedicated reset page method (#673) 666501e
 * feat(getState): remove filter option (#707) ac52791
 * feat(getState): remove getState (#708) 7de698c
 * feat(requestBuilder): prevent needless extra requests for empty refinements (#737) db0a392
 * feat(search): allow the search only with Derived Helpers (#704) aa128fc
 * feat(SearchParameters): avoid undefined values (#703) 9757e0a
 * feat(typescript): move typings inline (#719) a12272e
 * fix(defaults): remove const 48a0c48
 * fix(errors): remove isRefined (#731) 5761885
 * fix(getConjunctiveRefinements): no error when requested facet is not conjunctive (#724) cf852e7
 * fix(getDisjunctiveRefinements): remove error (#725) 211e390
 * fix(getExcludeRefinements): replace error by default value (#726) 9d7ae87
 * fix(getFacetStats): remove error (#721) 96b6ec8
 * fix(getFacetValues): don't throw error when there's no facet (#720) e15e39e
 * fix(getHierarchicalFacetBreadcrumb): don't throw an error (#723) 40e1d61
 * fix(isDisjunctiveFacetRefined): return false if not in disjunctiveFacets (#729) 13ec09b
 * fix(isExcludeRefined): remove error in favor of false (#728) 3f0ab6b
 * fix(isFacetRefined): return false if facet isn't declared (#727) 7151f56
 * fix(isHierarchicalFacetRefined): return false if refinement isn't a facet (#730) 89fa010
 * fix(lodash/intersection): replace with custom implementation (#718) 00dfb4e
 * fix(removeXFacet): make sure this fully removes empty arrays (#743) ea5a22a
 * fix(results): remove lodash looping over objects (#648) bb025c2, closes #258
 * fix(sortBy): compare whole prefix instead of first character (#702) b85fb50, closes #702
 * fix(toggleRefinement): keep an empty array when clearing (#738) 5b3fc11
 * fix(types): add state.removeNumericRefinement (#742) e58c24a
 * refactor(addAgent): remove duplicate code (#657) d023efd
 * refactor(error): use object vs list of arguments (#700) 722eceb
 * refactor(lodash): compact (#689) 284efa5
 * refactor(lodash): forOwn (#697) eae367a
 * refactor(lodash): intersection (#696) 25822a5
 * refactor(lodash): map & trim (#679) 357fcb7
 * refactor(lodash): merge (#694) 92bced4
 * refactor(lodash): partial & partialRight (#693) 7ceea2f
 * refactor(lodash): remove filter (#685) 249d2e6
 * refactor(lodash): remove flatten (#695) 9da0e08
 * refactor(lodash): remove forEach (#674) 8c93765
 * refactor(lodash): remove reduce (#678) 7907805
 * refactor(lodash): remove simple functions (#656) c309ffa
 * refactor(lodash): remove startsWith (#690) bb00933
 * refactor(lodash): replace defaults with pure alternative (#692) ee07132
 * refactor(lodash): replace find & findIndex (#687) 92e7c23
 * refactor(lodash): replace orderBy (#698) bb2b31e
 * refactor(lodash): sumBy (#688) a538bd9
 * refactor(result): use object vs list of arguments (#699) 643f18e
 * refactor(search): emit object (#683) 46c7d7d
 * refactor(searchForFacetValues): use object vs list of arguments (#684) ab8e9c5
 * refactor: remove getQueryParameter (#713) d9dfac4
 * refactor(searchOnce): use object vs list of arguments (#681) 42b40d3
 * refactor(SearchParameters): removes default values (#670) b15696b
 * refactor(url): remove url helpers (#652) 52e22f4
 * test(sffv): no longer test impossible responses (#686) fd878e8

### BREAKING CHANGE

* getState(filters) is replaced my manually filtering the returned object
* removed helper.isRefined, use helper.hasRefinements instead
* SearchParameters.filter is removed

* doc(filter): remove reference
* use helper.state instead of helper.getState()
dhayab pushed a commit to algolia/instantsearch that referenced this pull request Jul 10, 2023
 * chore(deps): update dependency algolia-frontend-components to v0.0.35 (algolia/algoliasearch-helper-js#605) algolia/algoliasearch-helper-js@0bb3578
 * chore(deps): update dependency algoliasearch to v3.32.0 (algolia/algoliasearch-helper-js#628) algolia/algoliasearch-helper-js@39cb552
 * chore(deps): update dependency babel-core to v6.26.3 (algolia/algoliasearch-helper-js#581) algolia/algoliasearch-helper-js@83213d7
 * chore(deps): update dependency browserify to v14.5.0 (algolia/algoliasearch-helper-js#582) algolia/algoliasearch-helper-js@855cf5d
 * chore(deps): update dependency handlebars to v4.1.0 (algolia/algoliasearch-helper-js#589) algolia/algoliasearch-helper-js@28fd11b
 * chore(deps): update dependency http-server to v0.11.1 (algolia/algoliasearch-helper-js#590) algolia/algoliasearch-helper-js@9534c17
 * chore(deps): update dependency mversion to v1.13.0 (algolia/algoliasearch-helper-js#630) algolia/algoliasearch-helper-js@20dce48
 * chore(deps): update dependency rimraf to v2.6.3 (algolia/algoliasearch-helper-js#596) algolia/algoliasearch-helper-js@0ed5fa9
 * chore: use only yarn (no more npm 👩‍🚒) (algolia/algoliasearch-helper-js#637) algolia/algoliasearch-helper-js@b5b0952
 * chore(deps): update st (algolia/algoliasearch-helper-js#625) algolia/algoliasearch-helper-js@81a30b5
 * chore(docs): change jade to pug (algolia/algoliasearch-helper-js#615) algolia/algoliasearch-helper-js@f1ef3b0, closes algolia/algoliasearch-helper-js#613
 * chore(docs): fix interpolation algolia/algoliasearch-helper-js@d591977
 * chore(docs): remove folder in  (algolia/algoliasearch-helper-js#616) algolia/algoliasearch-helper-js@0e9332f
 * docs(init): use toggleFacetRefinement instead (algolia/algoliasearch-helper-js#622) algolia/algoliasearch-helper-js@d07614b
 * docs(instantiate): use existing signature of toggleRefine (algolia/algoliasearch-helper-js#621) algolia/algoliasearch-helper-js@c35bec9
 * docs: fix InstantSearch link (algolia/algoliasearch-helper-js#640) algolia/algoliasearch-helper-js@66dfa0c, closes algolia/algoliasearch-helper-js#640
 * docs: fix typo on hierarchical facets (algolia/algoliasearch-helper-js#646) algolia/algoliasearch-helper-js@940e2c6, closes algolia/algoliasearch-helper-js#646
 * feat(sffv): throw an error if it's called and the client doesn't have the functions (algolia/algoliasearch-helper-js#623) algolia/algoliasearch-helper-js@9002c31
 * fix(results): remove lodash looping over objects (algolia/algoliasearch-helper-js#648) algolia/algoliasearch-helper-js@b1ccd5e, closes algolia/algoliasearch-helper-js#258
 * fix(ua): change the User-Agent to use the new specs lib (version) (algolia/algoliasearch-helper-js#647) algolia/algoliasearch-helper-js@ec2c6ee
 * refactor(events): replace util.inherits by inline (algolia/algoliasearch-helper-js#653) algolia/algoliasearch-helper-js@0e227f9
 * test(client): update index name (algolia/algoliasearch-helper-js#619) algolia/algoliasearch-helper-js@ba68a3c
 * Update README.md algolia/algoliasearch-helper-js@808a736
dhayab pushed a commit to algolia/instantsearch that referenced this pull request Jul 10, 2023
…ch-helper-js#648)

* fix(lodash): remove collection methods

done: sumBy, map, find (except one occurence)
todo: includes, orderBy

* fix(getHierarchicalRefinement): deal correctly with no default separator

* finished migration

got rid of lodash/get globally!

* test(results): add test for facet values

* chore(lodash): remove trivial usage of map

* chore(results): remove indexOf

* chore(lodash): migrate filterState

* chore(lodash): remove reduce in formatSort

* test(helper): add failing test case for helper having .length value

* fix(hierarchical): fix "length" bug (and simplify in the meantime)

* chore: fix ran tests

* chore(results): remove lodash.includes

* refactor(lodash): remove isString & indexOf (34.9kB)

* apply feedback from review

* fixes on hierarchical

correct "exhaustive"
fixes algolia/algoliasearch-helper-js#258
keep "path" as name; even if it's a bug

* chore: remove comment

* Revert "fixes on hierarchical"

This reverts commit 042f7220c500e4f397b2da03f4fffb44f8ab47a3.

* undo hierarchical changes

* chore: undo more fixes

* chore: remove dumb comment lol

* feedback from review

* fix(hierarchical): add exhaustive & lodash looping (algolia/algoliasearch-helper-js#651)

* Revert "Revert "fixes on hierarchical""

This reverts commit abfea9177e300207636c5cbd48ddc21b8213137a.

* Revert "undo hierarchical changes"

This reverts commit a50a8ae00cafa4373a35612795f378d6b33e1892.

* Revert "chore: undo more fixes"

This reverts commit 78d06c21d65396a13d23443cd0ce7dc612bb332e.

* Revert "chore: remove dumb comment lol"

This reverts commit 8054352042a47f27ab66f56ccf3a347787c86888.

* feedback from review

* chore(test): fix integration
dhayab pushed a commit to algolia/instantsearch that referenced this pull request Jul 10, 2023
 *  fix(merge): change implementation  (algolia/algoliasearch-helper-js#716) algolia/algoliasearch-helper-js@736c8ae
 * chore: mention remaining changes algolia/algoliasearch-helper-js@1f7ea90
 * chore(deps): update circleci/node:8.15.1 docker digest to ef1a0c4 (algolia/algoliasearch-helper-js#715) algolia/algoliasearch-helper-js@4b2c788
 * chore(lodash): remove _.omit (algolia/algoliasearch-helper-js#655) algolia/algoliasearch-helper-js@055257d
 * chore(lodash): remove lodash from dependency list (algolia/algoliasearch-helper-js#705) algolia/algoliasearch-helper-js@d1be213, closes algolia/algoliasearch-helper-js#552
 * chore(release): allow canary release (algolia/algoliasearch-helper-js#712) algolia/algoliasearch-helper-js@a72f0de
 * chore(removeHierarchicalFacetRefinement): remove error if not refined (algolia/algoliasearch-helper-js#747) algolia/algoliasearch-helper-js@89dc193
 * chore: merge develop into master (algolia/algoliasearch-helper-js#750) algolia/algoliasearch-helper-js@77e3e84
 * chore: remove Bower support (algolia/algoliasearch-helper-js#711) algolia/algoliasearch-helper-js@69d00a5
 * chore(ts): add methods algolia/algoliasearch-helper-js@3c4ee8f
 * chore(ts): add ruleContexts to SP algolia/algoliasearch-helper-js@bdb516e
 * chore(ts): add searchOnlyWithDerivedHelpers (algolia/algoliasearch-helper-js#739) algolia/algoliasearch-helper-js@1f5dd4c
 * chore(ts): publish definition file too algolia/algoliasearch-helper-js@4949596
 * chore(TS): isNumericRefined has only one required argument algolia/algoliasearch-helper-js@1d4e7fb
 * chore(warn): remove unused function (lodash.bind) (algolia/algoliasearch-helper-js#682) algolia/algoliasearch-helper-js@da805d9
 * chore: update release command algolia/algoliasearch-helper-js@3255f36
 * docs: add link to wiki algolia/algoliasearch-helper-js@f0915c3
 * docs: update event signature (algolia/algoliasearch-helper-js#701) algolia/algoliasearch-helper-js@1a0c343
 * docs(migration): mention changed methods (algolia/algoliasearch-helper-js#732) algolia/algoliasearch-helper-js@1c9bdcd
 * docs(next): add migration guide algolia/algoliasearch-helper-js@dfb08f0
 * docs(serverUsed): mention getRankingInfo (algolia/algoliasearch-helper-js#706) algolia/algoliasearch-helper-js@4a8d8f7, closes algolia/algoliasearch-helper-js#500
 * feat: implement dedicated reset page method (algolia/algoliasearch-helper-js#673) algolia/algoliasearch-helper-js@8fa4ee4
 * feat(getState): remove filter option (algolia/algoliasearch-helper-js#707) algolia/algoliasearch-helper-js@681bf17
 * feat(getState): remove getState (algolia/algoliasearch-helper-js#708) algolia/algoliasearch-helper-js@b951579
 * feat(requestBuilder): prevent needless extra requests for empty refinements (algolia/algoliasearch-helper-js#737) algolia/algoliasearch-helper-js@a03ff29
 * feat(search): allow the search only with Derived Helpers (algolia/algoliasearch-helper-js#704) algolia/algoliasearch-helper-js@3da864c
 * feat(SearchParameters): avoid undefined values (algolia/algoliasearch-helper-js#703) algolia/algoliasearch-helper-js@7812536
 * feat(typescript): move typings inline (algolia/algoliasearch-helper-js#719) algolia/algoliasearch-helper-js@68af05e
 * fix(defaults): remove const algolia/algoliasearch-helper-js@7df8754
 * fix(errors): remove isRefined (algolia/algoliasearch-helper-js#731) algolia/algoliasearch-helper-js@1da0000
 * fix(getConjunctiveRefinements): no error when requested facet is not conjunctive (algolia/algoliasearch-helper-js#724) algolia/algoliasearch-helper-js@b7c9a3f
 * fix(getDisjunctiveRefinements): remove error (algolia/algoliasearch-helper-js#725) algolia/algoliasearch-helper-js@c573d33
 * fix(getExcludeRefinements): replace error by default value (algolia/algoliasearch-helper-js#726) algolia/algoliasearch-helper-js@77f6770
 * fix(getFacetStats): remove error (algolia/algoliasearch-helper-js#721) algolia/algoliasearch-helper-js@3b593d7
 * fix(getFacetValues): don't throw error when there's no facet (algolia/algoliasearch-helper-js#720) algolia/algoliasearch-helper-js@cfdbc5b
 * fix(getHierarchicalFacetBreadcrumb): don't throw an error (algolia/algoliasearch-helper-js#723) algolia/algoliasearch-helper-js@4a75244
 * fix(isDisjunctiveFacetRefined): return false if not in disjunctiveFacets (algolia/algoliasearch-helper-js#729) algolia/algoliasearch-helper-js@7cb124d
 * fix(isExcludeRefined): remove error in favor of false (algolia/algoliasearch-helper-js#728) algolia/algoliasearch-helper-js@238e975
 * fix(isFacetRefined): return false if facet isn't declared (algolia/algoliasearch-helper-js#727) algolia/algoliasearch-helper-js@c2d8afe
 * fix(isHierarchicalFacetRefined): return false if refinement isn't a facet (algolia/algoliasearch-helper-js#730) algolia/algoliasearch-helper-js@0a913c7
 * fix(lodash/intersection): replace with custom implementation (algolia/algoliasearch-helper-js#718) algolia/algoliasearch-helper-js@dd63327
 * fix(removeXFacet): make sure this fully removes empty arrays (algolia/algoliasearch-helper-js#743) algolia/algoliasearch-helper-js@33f256c
 * fix(results): remove lodash looping over objects (algolia/algoliasearch-helper-js#648) algolia/algoliasearch-helper-js@f3287d8, closes algolia/algoliasearch-helper-js#258
 * fix(sortBy): compare whole prefix instead of first character (algolia/algoliasearch-helper-js#702) algolia/algoliasearch-helper-js@21fcd34, closes algolia/algoliasearch-helper-js#702
 * fix(toggleRefinement): keep an empty array when clearing (algolia/algoliasearch-helper-js#738) algolia/algoliasearch-helper-js@9ab228d
 * fix(types): add state.removeNumericRefinement (algolia/algoliasearch-helper-js#742) algolia/algoliasearch-helper-js@e8b4b34
 * refactor(addAgent): remove duplicate code (algolia/algoliasearch-helper-js#657) algolia/algoliasearch-helper-js@050a17f
 * refactor(error): use object vs list of arguments (algolia/algoliasearch-helper-js#700) algolia/algoliasearch-helper-js@c70d6ee
 * refactor(lodash): compact (algolia/algoliasearch-helper-js#689) algolia/algoliasearch-helper-js@7a5af0e
 * refactor(lodash): forOwn (algolia/algoliasearch-helper-js#697) algolia/algoliasearch-helper-js@a0af759
 * refactor(lodash): intersection (algolia/algoliasearch-helper-js#696) algolia/algoliasearch-helper-js@0077f50
 * refactor(lodash): map & trim (algolia/algoliasearch-helper-js#679) algolia/algoliasearch-helper-js@a8c5f2c
 * refactor(lodash): merge (algolia/algoliasearch-helper-js#694) algolia/algoliasearch-helper-js@7cb5357
 * refactor(lodash): partial & partialRight (algolia/algoliasearch-helper-js#693) algolia/algoliasearch-helper-js@151685d
 * refactor(lodash): remove filter (algolia/algoliasearch-helper-js#685) algolia/algoliasearch-helper-js@16a3aff
 * refactor(lodash): remove flatten (algolia/algoliasearch-helper-js#695) algolia/algoliasearch-helper-js@d2b667f
 * refactor(lodash): remove forEach (algolia/algoliasearch-helper-js#674) algolia/algoliasearch-helper-js@58fd08f
 * refactor(lodash): remove reduce (algolia/algoliasearch-helper-js#678) algolia/algoliasearch-helper-js@187ae67
 * refactor(lodash): remove simple functions (algolia/algoliasearch-helper-js#656) algolia/algoliasearch-helper-js@ed2a393
 * refactor(lodash): remove startsWith (algolia/algoliasearch-helper-js#690) algolia/algoliasearch-helper-js@75f1035
 * refactor(lodash): replace defaults with pure alternative (algolia/algoliasearch-helper-js#692) algolia/algoliasearch-helper-js@c5b0c89
 * refactor(lodash): replace find & findIndex (algolia/algoliasearch-helper-js#687) algolia/algoliasearch-helper-js@c190cb3
 * refactor(lodash): replace orderBy (algolia/algoliasearch-helper-js#698) algolia/algoliasearch-helper-js@7805cd8
 * refactor(lodash): sumBy (algolia/algoliasearch-helper-js#688) algolia/algoliasearch-helper-js@a037c6f
 * refactor(result): use object vs list of arguments (algolia/algoliasearch-helper-js#699) algolia/algoliasearch-helper-js@f4ea805
 * refactor(search): emit object (algolia/algoliasearch-helper-js#683) algolia/algoliasearch-helper-js@1029dcd
 * refactor(searchForFacetValues): use object vs list of arguments (algolia/algoliasearch-helper-js#684) algolia/algoliasearch-helper-js@d2acced
 * refactor: remove getQueryParameter (algolia/algoliasearch-helper-js#713) algolia/algoliasearch-helper-js@6b8c643
 * refactor(searchOnce): use object vs list of arguments (algolia/algoliasearch-helper-js#681) algolia/algoliasearch-helper-js@a86581a
 * refactor(SearchParameters): removes default values (algolia/algoliasearch-helper-js#670) algolia/algoliasearch-helper-js@2679f99
 * refactor(url): remove url helpers (algolia/algoliasearch-helper-js#652) algolia/algoliasearch-helper-js@b9e3fd9
 * test(sffv): no longer test impossible responses (algolia/algoliasearch-helper-js#686) algolia/algoliasearch-helper-js@09e475f

### BREAKING CHANGE

* getState(filters) is replaced my manually filtering the returned object
* removed helper.isRefined, use helper.hasRefinements instead
* SearchParameters.filter is removed

* doc(filter): remove reference
* use helper.state instead of helper.getState()
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid to rely on Lodash to loop over collections
4 participants