neon_arch commited on
Commit
8133de1
1 Parent(s): a3edf70

✨ feat: add check to conditionaly pass empty_result_set to true to UI

Browse files
Files changed (1) hide show
  1. src/server/routes.rs +6 -3
src/server/routes.rs CHANGED
@@ -22,7 +22,7 @@ use serde::Deserialize;
22
  /// of the search url.
23
  /// * `page` - It stores the search parameter `page` (or pageno in simple words)
24
  /// of the search url.
25
- #[derive(Debug, Deserialize)]
26
  struct SearchParams {
27
  q: Option<String>,
28
  page: Option<u32>,
@@ -137,12 +137,15 @@ pub async fn search(
137
  Err(_) => {
138
  let mut results_json: crate::search_results_handler::aggregation_models::SearchResults = match req.cookie("appCookie") {
139
  Some(cookie_value) => {
140
- let cookie_value:Cookie = serde_json::from_str(cookie_value.name_value().1).unwrap();
141
- aggregate(query.clone(), page, config.aggregator.random_delay, config.debug, cookie_value.engines).await?
142
  },
143
  None => aggregate(query.clone(), page, config.aggregator.random_delay, config.debug, config.upstream_search_engines.clone()).await?,
144
  };
145
  results_json.add_style(config.style.clone());
 
 
 
146
  redis_cache
147
  .cache_results(serde_json::to_string(&results_json)?, &page_url)?;
148
  let page_content: String = hbs.render("search", &results_json)?;
 
22
  /// of the search url.
23
  /// * `page` - It stores the search parameter `page` (or pageno in simple words)
24
  /// of the search url.
25
+ #[derive(Deserialize)]
26
  struct SearchParams {
27
  q: Option<String>,
28
  page: Option<u32>,
 
137
  Err(_) => {
138
  let mut results_json: crate::search_results_handler::aggregation_models::SearchResults = match req.cookie("appCookie") {
139
  Some(cookie_value) => {
140
+ let cookie_value:Cookie = serde_json::from_str(cookie_value.name_value().1)?;
141
+ aggregate(query.clone(), page, config.aggregator.random_delay, config.debug, cookie_value.engines).await?
142
  },
143
  None => aggregate(query.clone(), page, config.aggregator.random_delay, config.debug, config.upstream_search_engines.clone()).await?,
144
  };
145
  results_json.add_style(config.style.clone());
146
+ if results_json.is_empty_result_set() {
147
+ results_json.set_empty_result_set();
148
+ }
149
  redis_cache
150
  .cache_results(serde_json::to_string(&results_json)?, &page_url)?;
151
  let page_content: String = hbs.render("search", &results_json)?;