-
Notifications
You must be signed in to change notification settings - Fork 164
Search handler and client with HTTP POST-based request serialization. #8892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,6 @@ enum SearchOrder { | |
/// WARNING: The value shouldn't be used anymore. | ||
/// | ||
/// TODO: remove in a future release. | ||
@Deprecated('Popularity is no longer used.') | ||
popularity, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional, but more of a convenience: if we keep it, the generated code uses it and analyzer complains about using a deprecated field. I did not want to remove it yet, but maybe we should? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the field. I think we did have enough time since we have changed from popularity to downloads. Old bookmarks may break, but that is going to happen no matter when we remove it. |
||
|
||
/// Search order should be in decreasing download counts. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:_pub_shared/search/search_form.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'search_request_data.g.dart'; | ||
|
||
@JsonSerializable() | ||
class SearchRequestData { | ||
final String? query; | ||
final List<String>? tags; | ||
final String? publisherId; | ||
final int? minPoints; | ||
final SearchOrder? order; | ||
final int? offset; | ||
final int? limit; | ||
final TextMatchExtent? textMatchExtent; | ||
|
||
SearchRequestData({ | ||
this.query, | ||
this.tags, | ||
this.publisherId, | ||
this.minPoints, | ||
this.order, | ||
this.offset, | ||
this.limit, | ||
this.textMatchExtent, | ||
}); | ||
|
||
factory SearchRequestData.fromJson(Map<String, dynamic> json) => | ||
_$SearchRequestDataFromJson(json); | ||
Map<String, dynamic> toJson() => _$SearchRequestDataToJson(this); | ||
} | ||
|
||
/// The scope (depth) of the text matching. | ||
enum TextMatchExtent { | ||
/// No text search is done. | ||
/// Requests with text queries will return a failure message. | ||
none, | ||
|
||
/// Text search is on package names. | ||
name, | ||
|
||
/// Text search is on package names, descriptions and topic tags. | ||
description, | ||
|
||
/// Text search is on names, descriptions, topic tags and readme content. | ||
readme, | ||
|
||
/// Text search is on names, descriptions, topic tags, readme content and API symbols. | ||
api, | ||
; | ||
|
||
/// Text search is on package names. | ||
bool shouldMatchName() => index >= name.index; | ||
|
||
/// Text search is on package names, descriptions and topic tags. | ||
bool shouldMatchDescription() => index >= description.index; | ||
|
||
/// Text search is on names, descriptions, topic tags and readme content. | ||
bool shouldMatchReadme() => index >= readme.index; | ||
|
||
/// Text search is on names, descriptions, topic tags, readme content and API symbols. | ||
bool shouldMatchApi() => index >= api.index; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to contradict the code below that branches on the method....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comment, it should handle both.