Skip to content

Commit 694f37c

Browse files
authored
Fix: search request update in latency-aware checks. (#8936)
1 parent 18ccff4 commit 694f37c

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

app/lib/search/search_service.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,7 @@ class ServiceSearchQuery {
189189
ServiceSearchQuery change({
190190
TextMatchExtent? textMatchExtent,
191191
}) {
192-
return ServiceSearchQuery(SearchRequestData(
193-
query: query,
194-
tags: _data.tags,
195-
publisherId: publisherId,
196-
order: order,
197-
minPoints: minPoints,
198-
offset: offset,
199-
limit: limit,
200-
textMatchExtent: textMatchExtent ?? this.textMatchExtent,
201-
));
192+
return ServiceSearchQuery(_data.replace(textMatchExtent: textMatchExtent));
202193
}
203194

204195
late final parsedQuery = ParsedQueryText.parse(_data.query);

app/test/service/entrypoint/search_index_test.dart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:_pub_shared/search/search_request_data.dart';
56
import 'package:path/path.dart' as p;
67
import 'package:pub_dev/search/search_service.dart';
78
import 'package:pub_dev/search/updater.dart';
@@ -28,14 +29,18 @@ void main() {
2829
description: 'Annotation metadata for JSON serialization.',
2930
tags: ['sdk:dart'],
3031
),
32+
PackageDocument(
33+
package: 'other_pkg',
34+
description: 'Some awesome package',
35+
),
3136
],
3237
snapshotPath,
3338
);
3439

3540
runner = await startSearchIsolate(snapshot: snapshotPath);
3641

3742
// index calling the sendport
38-
final searchIndex = IsolateSearchIndex(runner);
43+
final searchIndex = LatencyAwareSearchIndex(IsolateSearchIndex(runner));
3944
expect(await searchIndex.isReady(), true);
4045

4146
// text query - result from package index
@@ -52,6 +57,18 @@ void main() {
5257
},
5358
],
5459
});
60+
61+
// packages-based filtering works
62+
final rs2 = await searchIndex.search(
63+
ServiceSearchQuery(SearchRequestData(packages: ['other_pkg'])));
64+
expect(rs2.toJson(), {
65+
'timestamp': isNotEmpty,
66+
'totalCount': 1,
67+
'sdkLibraryHits': [],
68+
'packageHits': [
69+
{'package': 'other_pkg', 'score': isNotNull}
70+
],
71+
});
5572
});
5673
}, timeout: Timeout(Duration(minutes: 5)));
5774
});

pkg/_pub_shared/lib/search/search_request_data.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class SearchRequestData {
9393
String? query,
9494
List<String>? tags,
9595
List<String>? packages,
96+
TextMatchExtent? textMatchExtent,
9697
}) {
9798
return SearchRequestData(
9899
query: query ?? this.query,
@@ -103,7 +104,7 @@ class SearchRequestData {
103104
order: order,
104105
offset: offset,
105106
limit: limit,
106-
textMatchExtent: textMatchExtent,
107+
textMatchExtent: textMatchExtent ?? this.textMatchExtent,
107108
);
108109
}
109110
}

0 commit comments

Comments
 (0)