Skip to content

Commit 8afe98d

Browse files
authored
fix(client): remove invalid maxFacetHits in SearchForHits extension (#153)
* fix(client): remove invalid `maxFacetHits` in `SearchForHits` extension * apply dart analyze suggestions * apply dart analyze suggestion for insights
1 parent 114f6eb commit 8afe98d

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

helper/lib/src/filter_group_converter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ final class FilterConverter {
8989
filter.attribute,
9090
filter.isNegated,
9191
);
92+
// ignore: unreachable_switch_default
9293
default:
9394
throw ArgumentError('Filter type ${filter.runtimeType} not supported');
9495
}

helper/lib/src/service/algolia_client_extensions.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ extension AlgolisSearchStateExt on SearchState {
3838
highlightPostTag: highlightPostTag,
3939
highlightPreTag: highlightPreTag,
4040
hitsPerPage: hitsPerPage,
41-
maxFacetHits: maxFacetHits,
4241
maxValuesPerFacet: maxValuesPerFacet,
4342
numericFilters: numericFilters,
4443
optionalFilters: optionalFilters,

helper/test/filter_converter_test.dart

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ void main() {
1010
final filterScore = Filter.facet('attributeA', true, score: 4);
1111

1212
const converter = FilterConverter();
13-
expect(converter.sql(filterTrue), '\"attributeA\":true');
14-
expect(converter.sql(filterFalse), '\"attributeA\":false');
15-
expect(converter.sql(filterTrue.not()), 'NOT \"attributeA\":true');
16-
expect(converter.sql(filterFalse.not()), 'NOT \"attributeA\":false');
17-
expect(converter.sql(filterScore), '\"attributeA\":true<score=4>');
13+
expect(converter.sql(filterTrue), '"attributeA":true');
14+
expect(converter.sql(filterFalse), '"attributeA":false');
15+
expect(converter.sql(filterTrue.not()), 'NOT "attributeA":true');
16+
expect(converter.sql(filterFalse.not()), 'NOT "attributeA":false');
17+
expect(converter.sql(filterScore), '"attributeA":true<score=4>');
1818
});
1919

2020
test('Filter facet Number', () {
@@ -23,11 +23,11 @@ void main() {
2323
final filterScore = Filter.facet('attributeA', 1, score: 2);
2424

2525
const converter = FilterConverter();
26-
expect(converter.sql(filterInt), '\"attributeA\":1');
27-
expect(converter.sql(filterDouble), '\"attributeA\":${1.0}');
28-
expect(converter.sql(filterDouble.not()), 'NOT \"attributeA\":${1.0}');
29-
expect(converter.sql(filterScore), '\"attributeA\":1<score=2>');
30-
expect(converter.sql(filterScore), '\"attributeA\":1<score=2>');
26+
expect(converter.sql(filterInt), '"attributeA":1');
27+
expect(converter.sql(filterDouble), '"attributeA":${1.0}');
28+
expect(converter.sql(filterDouble.not()), 'NOT "attributeA":${1.0}');
29+
expect(converter.sql(filterScore), '"attributeA":1<score=2>');
30+
expect(converter.sql(filterScore), '"attributeA":1<score=2>');
3131
});
3232

3333
test('Filter facet String', () {
@@ -37,15 +37,15 @@ void main() {
3737
final filterScore = Filter.facet('attributeA', 'valueA', score: 1);
3838

3939
const converter = FilterConverter();
40-
expect(converter.sql(filter), '\"attributeA\":\"valueA\"');
41-
expect(converter.sql(filterNegate), 'NOT \"attributeA\":\"valueA\"');
40+
expect(converter.sql(filter), '"attributeA":"valueA"');
41+
expect(converter.sql(filterNegate), 'NOT "attributeA":"valueA"');
4242
expect(
4343
converter.sql(filterSpace),
44-
'\"attributeA\":\"value with space\"',
44+
'"attributeA":"value with space"',
4545
);
4646
expect(
4747
converter.sql(filterScore),
48-
'\"attributeA\":\"valueA\"<score=1>',
48+
'"attributeA":"valueA"<score=1>',
4949
);
5050
});
5151
});
@@ -64,13 +64,13 @@ void main() {
6464
Filter.comparison('attributeA', NumericOperator.greaterOrEquals, 5);
6565

6666
const converter = FilterConverter();
67-
expect(converter.sql(less), '\"attributeA\" < 5');
68-
expect(converter.sql(lessOrEquals), '\"attributeA\" <= 5');
69-
expect(converter.sql(equals), '\"attributeA\" = 5');
70-
expect(converter.sql(notEquals), '\"attributeA\" != 5');
71-
expect(converter.sql(greater), '\"attributeA\" > 5');
72-
expect(converter.sql(greaterOrEquals), '\"attributeA\" >= 5');
73-
expect(converter.sql(less.not()), 'NOT \"attributeA\" < 5');
67+
expect(converter.sql(less), '"attributeA" < 5');
68+
expect(converter.sql(lessOrEquals), '"attributeA" <= 5');
69+
expect(converter.sql(equals), '"attributeA" = 5');
70+
expect(converter.sql(notEquals), '"attributeA" != 5');
71+
expect(converter.sql(greater), '"attributeA" > 5');
72+
expect(converter.sql(greaterOrEquals), '"attributeA" >= 5');
73+
expect(converter.sql(less.not()), 'NOT "attributeA" < 5');
7474
});
7575

7676
test('Filter numeric range', () {
@@ -80,17 +80,17 @@ void main() {
8080
Filter.range('attributeA', lowerBound: 0.0, upperBound: 6.0);
8181

8282
const converter = FilterConverter();
83-
expect(converter.sql(filterInt), '\"attributeA\":0 TO 6');
84-
expect(converter.sql(filterDouble), '\"attributeA\":${0.0} TO ${6.0}');
85-
expect(converter.sql(filterInt.not()), 'NOT \"attributeA\":0 TO 6');
83+
expect(converter.sql(filterInt), '"attributeA":0 TO 6');
84+
expect(converter.sql(filterDouble), '"attributeA":${0.0} TO ${6.0}');
85+
expect(converter.sql(filterInt.not()), 'NOT "attributeA":0 TO 6');
8686
});
8787
});
8888

8989
test('Filter tag SQL', () {
9090
final filter = Filter.tag('valueA');
9191
const converter = FilterConverter();
92-
expect(converter.sql(filter), '_tags:\"valueA\"');
93-
expect(converter.sql(filter.not()), 'NOT _tags:\"valueA\"');
92+
expect(converter.sql(filter), '_tags:"valueA"');
93+
expect(converter.sql(filter.not()), 'NOT _tags:"valueA"');
9494
});
9595

9696
group('Filter group SQL', () {

insights/lib/src/algolia_event_service.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:algolia_client_insights/algolia_client_insights.dart';
2-
import 'package:collection/collection.dart';
32
import 'package:logging/logging.dart';
43

54
import 'event.dart';
@@ -42,8 +41,8 @@ class AlgoliaEventService implements EventService {
4241
void send(List<Event> events) => _client
4342
.pushEvents(
4443
insightsEvents: InsightsEvents(
45-
events: events.map((e) => e.toAlgoliaEvent()).whereNotNull(),
46-
),
44+
events:
45+
events.map((e) => e.toAlgoliaEvent()).where((e) => e != null)),
4746
)
4847
.then(
4948
(_) => _log.fine('Events upload: $events'),

0 commit comments

Comments
 (0)