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

Commit 990f8bc

Browse files
authored
fix(facetOrdering): make sure ordered facets is a dense array (#879)
* fix(facetOrdering): make sure ordered facets is a dense array Otherwise the "undefined" values (are ordered, but not in the results) take up place and it messes up the limits. * update test name
1 parent b5b3d72 commit 990f8bc

File tree

3 files changed

+371
-0
lines changed

3 files changed

+371
-0
lines changed

src/SearchResults/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ function sortViaFacetOrdering(facetValues, facetOrdering) {
728728
}
729729
});
730730

731+
orderedFacets = orderedFacets.filter(function(facet) {
732+
return facet;
733+
});
734+
731735
var sortRemainingBy = facetOrdering.sortRemainingBy;
732736
var ordering;
733737
if (sortRemainingBy === 'hidden') {

test/spec/SearchResults/getFacetValues-facetOrdering.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,3 +779,22 @@ describe('hierarchical facet', function() {
779779
expect(facetValues).toEqual(expected);
780780
});
781781
});
782+
783+
test('does not return empty items', function() {
784+
var rawResults = require('./getFacetValues/sparse.json');
785+
var results = new SearchResults(new SearchParameters({
786+
disjunctiveFacets: ['brands']
787+
}), rawResults.results);
788+
789+
expect(results.getFacetValues('brands', {facetOrdering: true})).toEqual([
790+
{name: 'Addo', count: 321, isRefined: false},
791+
{name: 'Paw Patrol', count: 130, isRefined: false},
792+
{name: 'Mattel', count: 586, isRefined: false},
793+
{name: 'Nick Jr.', count: 147, isRefined: false},
794+
{name: 'Early Learning Centre', count: 292, isRefined: false},
795+
{name: 'Hot Wheels', count: 94, isRefined: false},
796+
{name: 'Fisher-Price', count: 104, isRefined: false},
797+
{name: 'Funko', count: 187, isRefined: false},
798+
{name: 'Nickelodeon', count: 230, isRefined: false}
799+
]);
800+
});
Lines changed: 348 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,348 @@
1+
{
2+
"results": [
3+
{
4+
"hits": [],
5+
"nbHits": 5859,
6+
"page": 0,
7+
"nbPages": 50,
8+
"hitsPerPage": 20,
9+
"facets": {
10+
"brands": {
11+
"Search by brand": 4809,
12+
"Mattel": 586,
13+
"Addo": 321,
14+
"Early Learning Centre": 292,
15+
"LEGO": 277,
16+
"Disney": 247,
17+
"Nickelodeon": 230,
18+
"Funko": 187,
19+
"Marvel": 174,
20+
"Nick Jr.": 147,
21+
"Playmobil": 144,
22+
"Paw Patrol": 130,
23+
"Barbie": 129,
24+
"VTech": 127,
25+
"Ravensburger": 124,
26+
"Star Wars": 111,
27+
"Fisher-Price": 104,
28+
"Thomas & Friends": 99,
29+
"Hot Wheels": 94,
30+
"Disney Princess": 93
31+
}
32+
},
33+
"exhaustiveFacetsCount": true,
34+
"exhaustiveNbHits": true,
35+
"exhaustiveTypo": true,
36+
"query": "",
37+
"params": "query=%20&highlightPreTag=__ais-highlight__&highlightPostTag=__%2Fais-highlight__&page=0&clickAnalytics=true&userToken=test&maxValuesPerFacet=20&facets=%5B%22ageRange%22%2C%22brands%22%5D&tagFilters=",
38+
"index": "test",
39+
"renderingContent": {
40+
"facetOrdering": {
41+
"values": {
42+
"brands": {
43+
"order": [
44+
"Superman",
45+
"Nintendo",
46+
"Zoomer",
47+
"Swingball",
48+
"Friends",
49+
"Blippi",
50+
"Addo",
51+
"L.O.L. Surprise O.M.G. Series Dolls",
52+
"Pop! Exclusive",
53+
"Hornby",
54+
"Jacks",
55+
"Out There",
56+
"Mattel Games",
57+
"L.O.L. Surprise Boy Series Dolls",
58+
"Boom City Racers",
59+
"Rainbow High",
60+
"Evi Love",
61+
"Baby Alive Dolls",
62+
"Paw Patrol",
63+
"Nerf Fortnite",
64+
"Star Wars: Episode IX",
65+
"Mattel",
66+
"LEGO Vidiyo",
67+
"Oh My Gif",
68+
"Nerf Alpha Strike",
69+
"B Friends Playsets and Accessories",
70+
"DC Super Hero Girls",
71+
"Star Wars Forces of Destiny",
72+
"Disney Pixar Toy Story 4",
73+
"Smashers",
74+
"Hatchimals Colleggtibles",
75+
"LEGO Minecraft",
76+
"Pop! DC Comics",
77+
"Monsterverse",
78+
"Nick Jr.",
79+
"Nickelodeon Experimake ",
80+
"Marvel Super Hero Mashers",
81+
"Tobi Friends",
82+
"Beanie Boo Buddies",
83+
"Captain Marvel",
84+
"The Original Fidget Cube",
85+
"Playmobil Wildlife",
86+
"Fortnite",
87+
"Bunchems",
88+
"Crate Creatures",
89+
"Ready Steady Dough Nick Jr",
90+
"Black Widow",
91+
"Cool Create",
92+
"Star Wars The Black Series",
93+
"Little Senses",
94+
"Pop! WWE",
95+
"Early Learning Centre",
96+
"LEGO Marvel Comics Super Heroes",
97+
"Hot Wheels",
98+
"Geomag",
99+
"Pikmi Pops Surprise",
100+
"Itty Bitty Pretty",
101+
"Sandsational",
102+
"LEGO Jurassic World",
103+
"Whizz World",
104+
"Fisher-Price",
105+
"Pitter Patter Pets",
106+
"Blaze and the Monster Machines",
107+
"Rainbocorns",
108+
"My Little Pony: The Movie",
109+
"Woodlets",
110+
"Twisty Petz",
111+
"Owleez",
112+
"Hairdorables",
113+
"Weebles",
114+
"Num Noms",
115+
"Fingerlings",
116+
"Elf",
117+
"Bing",
118+
"Star Wars - The Mandalorian",
119+
"Laugh & Learn",
120+
"Playskool Marvel Super Hero Adventures",
121+
"Pop! Disney",
122+
"Busy Me",
123+
"Pop! Retro Toys",
124+
"Collins Key",
125+
"Scooby Doo",
126+
"JoJo Bows",
127+
"Justice League",
128+
"Scruff A Luvs",
129+
"Vex Robotics",
130+
"Fart Ninja ",
131+
"Wubble",
132+
"Pop! Women of Power",
133+
"Star Wars - The Last Jedi",
134+
"B Friends",
135+
"Unique Boutique",
136+
"The LEGO Movie 2",
137+
"Pop! Marvel",
138+
"PJ Masks",
139+
"Pop! Movies",
140+
"Disney Cars 3",
141+
"VTech Toot Toot Friends",
142+
"L.O.L Surprise Dolls",
143+
"Ricky Zoom",
144+
"Disney Princess Belle",
145+
"Disney Princess Rapunzel",
146+
"Dolls World",
147+
"Lollipets",
148+
"Playmobil Country",
149+
"B Friends Clothes",
150+
"LEGO Avengers Endgame",
151+
"Real Littles ",
152+
"Tom & Jerry ",
153+
"Playmobil Fairies",
154+
"Transformers Construct Bots",
155+
"Bakugan",
156+
"K'nex",
157+
"Super Mario",
158+
"Mr Potato Head",
159+
"Love Diana ",
160+
"Jurassic World",
161+
"Playgro",
162+
"Baby Clementoni",
163+
"Playmobil Spirit",
164+
"Muddy Puddle Walk",
165+
"VTech Kiddi",
166+
"Playmobil Summer Fun",
167+
"Disney Incredibles 2",
168+
"LEGO Disney Princess",
169+
"Pop! My Little Pony",
170+
"Bush Baby World",
171+
"Dreamworks Dragons",
172+
"Shopkins",
173+
"Big City",
174+
"My Little Pony",
175+
"Capsule Chix",
176+
"Mini Artist",
177+
"Happyland",
178+
"Paw Patrol Jungle Rescue",
179+
"Top Wing",
180+
"Dreamworks Trolls Toys",
181+
"Sylvanian Families Town",
182+
"Hatchimals",
183+
"Paw Patrol Sea Patrol",
184+
"Kindi Kids Minis",
185+
"Playskool",
186+
"Paw Patrol Dino Rescue",
187+
"Playmobil City",
188+
"Little Lot",
189+
"LEGO Star Wars Episodes I -VI",
190+
"Paw Patrol Ultimate Rescue",
191+
"Ka Wazie",
192+
"Rosebud Village",
193+
"Pop! Keychain",
194+
"L.O.L. Surprise Remix Series Dolls",
195+
"Thomas & Friends Trackmaster",
196+
"B Friends Furniture",
197+
"Orchard Toys",
198+
"Steffi",
199+
"Funko",
200+
"Disney Frozen Fever",
201+
"Pop! Games",
202+
"Secret Crush",
203+
"Out and About",
204+
"Moon and Me",
205+
"Marvel Super Hero Mashers Micro",
206+
"Kinetic Sand",
207+
"Micro Machines",
208+
"Build-A-Bear Workshop",
209+
"Pomsies",
210+
"Baby Shark",
211+
"Playmobil Princess",
212+
"Sparkle Girlz",
213+
"All Elite Wrestling",
214+
"BABY Born Interactive",
215+
"Nickelodeon",
216+
"LEGO City Airport",
217+
"Cutetitos",
218+
"Hatchimals Surprise",
219+
"Vet Squad",
220+
"Starlink",
221+
"Scalextric",
222+
"CupCake",
223+
"Vtech Pre-school",
224+
"Ryan's World ",
225+
"BTS - Bangtan Boys",
226+
"VTech Toot Toot Animals",
227+
"L.O.L. Surprise J.K. Series Dolls",
228+
"LEGO City Coast Guard",
229+
"Cra-Z-Art",
230+
"L.O.L. Surprise Present Surprise Series Dolls",
231+
"Play & Win",
232+
"Blume Dolls",
233+
"Rizmo",
234+
"Boxer Robot",
235+
"Dolu",
236+
"Stretch Armstrong",
237+
"Stickle Bricks",
238+
"Stormblasters",
239+
"Disney Princess Cinderella",
240+
"Steffi Love",
241+
"Feber",
242+
"Pop! Rocks",
243+
"Minions Movie",
244+
"Luvabella",
245+
"LEGO City Space",
246+
"Fast and Furious",
247+
"Top Trumps",
248+
"LEGO Trolls",
249+
"DC Super Friends",
250+
"Nerf Laser Ops",
251+
"Nickelodeon Liquid Lava Sand",
252+
"LEGO City Police",
253+
"LEGO BrickHeadz",
254+
"Minecraft",
255+
"Out of the Box",
256+
"5 Surprise",
257+
"Avengers: Endgame",
258+
"Disney Princess Ariel",
259+
"Block Tech",
260+
"Out To Impress",
261+
"Moonlite",
262+
"Transformers: Bumblebee",
263+
"Play-Doh Kitchen Creations",
264+
"Superthings",
265+
"Nickelodeon Liquid Lava Putty",
266+
"Star Wars Rogue One",
267+
"FailFix",
268+
"Peppa Pig Holiday",
269+
"LEGO City Great Vehicles",
270+
"LEGO Dots",
271+
"Marvel Black Panther",
272+
"Goo Jit Zu",
273+
"Playmobil Special Plus",
274+
"Matchbox",
275+
"Engino",
276+
"Pop! Television",
277+
"Polly Pocket",
278+
"Despicable Me",
279+
"Bunch O Balloons",
280+
"Match Attax",
281+
"Science Museum Toys",
282+
"Monster Jam",
283+
"Fingerlings Untamed",
284+
"Disney Frozen 2",
285+
"Roblox",
286+
"LEGO City Fire",
287+
"VTech Toot Toot",
288+
"Hero Mashers",
289+
"Sonic The Hedgehog",
290+
"LEGO DC Comics Super Heroes",
291+
"Ty Beanie Babies",
292+
"Playmobil 123",
293+
"Be My Baby",
294+
"Transformers Studio Series",
295+
"Kindi Kids",
296+
"Star Wars The Rise of Skywalker",
297+
"LEGO Super Mario",
298+
"LEGO City Town",
299+
"Squishmallows",
300+
"B Friends Dolls",
301+
"Titan Hero",
302+
"Batman-Missions",
303+
"Pop! Animation",
304+
"Little Live Pets",
305+
"Back To The Future",
306+
"Mi-Mic",
307+
"Addo Games",
308+
"Robot Wars",
309+
"Playskool Heroes Rescue Bots",
310+
"LEGO Speed Champions",
311+
"Paw Patrol Mighty Pups",
312+
"Fuggler",
313+
"DC Comics",
314+
"Schleich",
315+
"Care Bears",
316+
"Paw Patrol Mission",
317+
"Masha and The Bear",
318+
"Pop! Star Wars",
319+
"Pop! AD Icons",
320+
"Snapstar",
321+
"Teletubbies",
322+
"Spirit",
323+
"Imaginext",
324+
"Robo Alive",
325+
"Enchantimals",
326+
"Blossom Farm",
327+
"Transformers Cyberverse",
328+
"Playmobil Family Fun",
329+
"Disney Frozen",
330+
"Candylocks",
331+
"Fisher Price Little People",
332+
"Snuggle Buddies",
333+
"Transformers Generations",
334+
"X Shot",
335+
"Star Wars The Force Awakens",
336+
"Awesome Animals",
337+
"Cool Create IDO3D",
338+
"Cave Club"
339+
],
340+
"sortRemainingBy": "hidden"
341+
}
342+
}
343+
}
344+
},
345+
"processingTimeMS": 1
346+
}
347+
]
348+
}

0 commit comments

Comments
 (0)