Skip to content

Commit 96ba185

Browse files
committed
fix: check filter Range bounds to include frames when min/max are default values
1 parent 9863e82 commit 96ba185

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

src/components/VideoExplorer/Home/MainView.js

+28-5
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class MainView extends React.Component {
174174
id: filterConfig.id,
175175
statKey: filterConfig.statKey,
176176
filterBehavior: filterConfig.filterBehavior,
177+
filterComponent: filterConfig.filterComponent,
177178
value: value
178179
})
179180
}
@@ -228,24 +229,46 @@ class MainView extends React.Component {
228229

229230
visibleFrames() {
230231
const { videoExplorerStore } = this.props;
231-
const { frames } = videoExplorerStore;
232+
const { selectedVideo, frames } = videoExplorerStore;
233+
234+
if(typeof selectedVideo === 'undefined')
235+
return [];
236+
237+
const { stats } = selectedVideo;
232238

233239
return frames
234240
.filter(f => {
235241
return typeof f !== undefined &&
236242
this.state.filters.every(uiFilter => {
237243
let isIncluded = true;
238244

245+
const { filterComponent } = uiFilter;
246+
const { statKeyLimits } = filterComponent;
247+
248+
// Check if uiFilter is set on min/max bounds
249+
// If it's the case, current frame should be included
250+
const isRangeBounds =
251+
typeof statKeyLimits !== 'undefined' &&
252+
statKeyLimits.length === 2 &&
253+
uiFilter.value[0] === parseFloat(stats[statKeyLimits[0]].toFixed(2)) &&
254+
uiFilter.value[1] === parseFloat(stats[statKeyLimits[1]].toFixed(2));
255+
239256
switch(uiFilter.filterBehavior) {
240257
case "arrayLengthInsideRange":
241258
isIncluded =
242-
f.stats[uiFilter.statKey].length >= uiFilter.value[0] &&
243-
f.stats[uiFilter.statKey].length <= uiFilter.value[1]
259+
isRangeBounds ||
260+
(
261+
f.stats[uiFilter.statKey].length >= uiFilter.value[0] &&
262+
f.stats[uiFilter.statKey].length <= uiFilter.value[1]
263+
)
244264
break;
245265
case "valueInsideRange":
246266
isIncluded =
247-
parseFloat(f.stats[uiFilter.statKey]) >= uiFilter.value[0] &&
248-
parseFloat(f.stats[uiFilter.statKey]) <= uiFilter.value[1]
267+
isRangeBounds ||
268+
(
269+
parseFloat(f.stats[uiFilter.statKey]) >= uiFilter.value[0] &&
270+
parseFloat(f.stats[uiFilter.statKey]) <= uiFilter.value[1]
271+
)
249272
break;
250273
case "someMoreThanAbsolutePercent":
251274
isIncluded = f.stats[uiFilter.statKey].some(val => {

0 commit comments

Comments
 (0)