Skip to content

Commit 48fa7c7

Browse files
committed
refactor(data): limit q search to name/title
- Removed description search - Updated documentation
1 parent 58f615b commit 48fa7c7

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

routes/api/v1/data/index.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Future<Response> onRequest(RequestContext context) async {
5353
///
5454
/// This handler implements model-specific filtering rules:
5555
/// - **Headlines (`model=headline`):**
56-
/// - Filterable by `q` (text query on title & description).
56+
/// - Filterable by `q` (text query on title only).
5757
/// If `q` is present, `categories` and `sources` are ignored.
5858
/// Example: `/api/v1/data?model=headline&q=Dart+Frog`
5959
/// - OR by a combination of:
@@ -66,7 +66,7 @@ Future<Response> onRequest(RequestContext context) async {
6666
/// - Other parameters for headlines (e.g., `countries`) will result in a 400 Bad Request.
6767
///
6868
/// - **Sources (`model=source`):**
69-
/// - Filterable by `q` (text query on name & description).
69+
/// - Filterable by `q` (text query on name only).
7070
/// If `q` is present, `countries`, `sourceTypes`, `languages` are ignored.
7171
/// Example: `/api/v1/data?model=source&q=Tech+News`
7272
/// - OR by a combination of:
@@ -80,14 +80,13 @@ Future<Response> onRequest(RequestContext context) async {
8080
/// - Other parameters for sources will result in a 400 Bad Request.
8181
///
8282
/// - **Categories (`model=category`):**
83-
/// - Filterable ONLY by `q` (text query on name & description).
83+
/// - Filterable ONLY by `q` (text query on name only).
8484
/// Example: `/api/v1/data?model=category&q=Technology`
8585
/// - Other parameters for categories will result in a 400 Bad Request.
8686
///
8787
/// - **Countries (`model=country`):**
88-
/// - Filterable ONLY by `q` (text query on name & isoCode).
88+
/// - Filterable ONLY by `q` (text query on name only).
8989
/// Example: `/api/v1/data?model=country&q=United`
90-
/// Example: `/api/v1/data?model=country&q=US`
9190
/// - Other parameters for countries will result in a 400 Bad Request.
9291
///
9392
/// - **Other Models (User, UserAppSettings, UserContentPreferences, AppConfig):**
@@ -123,7 +122,7 @@ Future<Response> _handleGet(
123122
final qValue = queryParams['q'];
124123
if (qValue != null && qValue.isNotEmpty) {
125124
specificQueryForClient['title_contains'] = qValue;
126-
specificQueryForClient['description_contains'] = qValue;
125+
// specificQueryForClient['description_contains'] = qValue; // Removed
127126
} else {
128127
if (queryParams.containsKey('categories')) {
129128
specificQueryForClient['category.id_in'] = queryParams['categories']!;
@@ -137,7 +136,7 @@ Future<Response> _handleGet(
137136
final qValue = queryParams['q'];
138137
if (qValue != null && qValue.isNotEmpty) {
139138
specificQueryForClient['name_contains'] = qValue;
140-
specificQueryForClient['description_contains'] = qValue;
139+
// specificQueryForClient['description_contains'] = qValue; // Removed
141140
} else {
142141
if (queryParams.containsKey('countries')) {
143142
specificQueryForClient['headquarters.iso_code_in'] =
@@ -156,15 +155,14 @@ Future<Response> _handleGet(
156155
final qValue = queryParams['q'];
157156
if (qValue != null && qValue.isNotEmpty) {
158157
specificQueryForClient['name_contains'] = qValue;
159-
specificQueryForClient['description_contains'] = qValue;
158+
// specificQueryForClient['description_contains'] = qValue; // Removed
160159
}
161160
case 'country':
162161
allowedKeys = {'q'};
163162
final qValue = queryParams['q'];
164163
if (qValue != null && qValue.isNotEmpty) {
165164
specificQueryForClient['name_contains'] = qValue;
166-
specificQueryForClient['iso_code_contains'] =
167-
qValue; // Also search iso_code
165+
// specificQueryForClient['iso_code_contains'] = qValue; // Removed
168166
}
169167
default:
170168
// For other models, pass through all non-standard query params directly.

0 commit comments

Comments
 (0)