Skip to content

Commit a255d8f

Browse files
Joan Reyerogithub-actions[bot]
andauthored
Fix average sentiment filter throwing a 500 error (#289)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent c24fdbd commit a255d8f

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

frontend/src/shared/fields/sentiment-field.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export default class SentimentField extends GenericField {
2525
value: 'neutral',
2626
label: 'Neutral',
2727
range: {
28-
gt: 33,
29-
lt: 67
28+
between: [33, 67]
3029
}
3130
},
3231
{

frontend/src/shared/filter/helpers/build-api-payload.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ function _buildAttributeBlock(attribute) {
4848
},
4949
{ or: [] }
5050
)
51+
} else if (attribute.name === 'averageSentiment') {
52+
return attribute.value.reduce(
53+
(obj, a) => {
54+
obj.or.push({
55+
averageSentiment: a.range
56+
})
57+
58+
return obj
59+
},
60+
{ or: [] }
61+
)
5162
} else if (attribute.name === 'type') {
5263
return {
5364
and: [

0 commit comments

Comments
 (0)