0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 05:58:21 -05:00

feat: remove the empty_result_set option and helper functions

This commit is contained in:
neon_arch 2023-07-17 13:03:20 +03:00
parent c5fca32553
commit 7e3b59e8c0
2 changed files with 0 additions and 18 deletions

View File

@ -155,7 +155,6 @@ pub struct SearchResults {
pub page_query: String, pub page_query: String,
pub style: Style, pub style: Style,
pub engine_errors_info: Vec<EngineErrorInfo>, pub engine_errors_info: Vec<EngineErrorInfo>,
pub empty_result_set: bool,
} }
impl SearchResults { impl SearchResults {
@ -179,7 +178,6 @@ impl SearchResults {
page_query, page_query,
style: Style::new("".to_string(), "".to_string()), style: Style::new("".to_string(), "".to_string()),
engine_errors_info, engine_errors_info,
empty_result_set: false,
} }
} }
@ -187,14 +185,4 @@ impl SearchResults {
pub fn add_style(&mut self, style: Style) { pub fn add_style(&mut self, style: Style) {
self.style = style; self.style = style;
} }
/// A function which checks whether the results stored are empty or not.
pub fn is_empty_result_set(&self) -> bool {
self.results.is_empty()
}
/// A setter function which sets the empty_result_set to true.
pub fn set_empty_result_set(&mut self) {
self.empty_result_set = true;
}
} }

View File

@ -161,12 +161,6 @@ async fn results(
} }
}; };
results_json.add_style(config.style.clone()); results_json.add_style(config.style.clone());
// check whether the results grabbed from the upstream engines are empty or
// not if they are empty then set the empty_result_set option to true in
// the result json.
if results_json.is_empty_result_set() {
results_json.set_empty_result_set();
}
redis_cache.cache_results(serde_json::to_string(&results_json)?, &url)?; redis_cache.cache_results(serde_json::to_string(&results_json)?, &url)?;
Ok(results_json) Ok(results_json)
} }