neon_arch commited on
Commit
173c6ba
1 Parent(s): b428ced

✨ feat: add code to handle aggregation when no engines are selected (#227)

Browse files
Files changed (1) hide show
  1. src/server/routes/search.rs +24 -11
src/server/routes/search.rs CHANGED
@@ -195,16 +195,26 @@ async fn results(
195
  .filter_map(|name| EngineHandler::new(name))
196
  .collect();
197
 
198
- aggregate(
199
- query,
200
- page,
201
- config.aggregator.random_delay,
202
- config.debug,
203
- &engines,
204
- config.request_timeout,
205
- safe_search,
206
- )
207
- .await?
 
 
 
 
 
 
 
 
 
 
208
  }
209
  None => {
210
  aggregate(
@@ -219,7 +229,10 @@ async fn results(
219
  .await?
220
  }
221
  };
222
- if results.engine_errors_info().is_empty() && results.results().is_empty() {
 
 
 
223
  results.set_filtered();
224
  }
225
  results.add_style(&config.style);
 
195
  .filter_map(|name| EngineHandler::new(name))
196
  .collect();
197
 
198
+ match engines.is_empty() {
199
+ false => {
200
+ aggregate(
201
+ query,
202
+ page,
203
+ config.aggregator.random_delay,
204
+ config.debug,
205
+ &engines,
206
+ config.request_timeout,
207
+ safe_search,
208
+ )
209
+ .await?
210
+ }
211
+ true => {
212
+ let mut search_results = SearchResults::default();
213
+ search_results.set_no_engines_selected();
214
+ search_results.set_page_query(query);
215
+ search_results
216
+ }
217
+ }
218
  }
219
  None => {
220
  aggregate(
 
229
  .await?
230
  }
231
  };
232
+ if results.engine_errors_info().is_empty()
233
+ && results.results().is_empty()
234
+ && !results.no_engines_selected()
235
+ {
236
  results.set_filtered();
237
  }
238
  results.add_style(&config.style);