From 141ae260662630b024b5de4c665ea6bca1fec454 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sat, 18 Nov 2023 21:38:02 +0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20remove=20the?= =?UTF-8?q?=20code=20to=20add=20the=20`query`=20&=20`style`=20in=20the=20`?= =?UTF-8?q?SearchResults`=20struct=20&=20also=20remove=20the=20associated?= =?UTF-8?q?=20fields=20from=20the=20struct=20(#302)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/aggregation_models.rs | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/models/aggregation_models.rs b/src/models/aggregation_models.rs index 660804e..680d222 100644 --- a/src/models/aggregation_models.rs +++ b/src/models/aggregation_models.rs @@ -1,11 +1,10 @@ //! This module provides public models for handling, storing and serializing of search results //! data scraped from the upstream search engines. +use super::engine_models::EngineError; use serde::{Deserialize, Serialize}; use smallvec::SmallVec; -use super::{engine_models::EngineError, parser_models::Style}; - /// A named struct to store the raw scraped search results scraped search results from the /// upstream search engines before aggregating it.It derives the Clone trait which is needed /// to write idiomatic rust using `Iterators`. @@ -109,10 +108,6 @@ impl EngineErrorInfo { pub struct SearchResults { /// Stores the individual serializable `SearchResult` struct into a vector of pub results: Vec, - /// Stores the current pages search query `q` provided in the search url. - pub page_query: String, - /// Stores the theming options for the website. - pub style: Style, /// Stores the information on which engines failed with their engine name /// and the type of error that caused it. pub engine_errors_info: Vec, @@ -142,15 +137,9 @@ impl SearchResults { /// the search url. /// * `engine_errors_info` - Takes an array of structs which contains information regarding /// which engines failed with their names, reason and their severity color name. - pub fn new( - results: Vec, - page_query: &str, - engine_errors_info: &[EngineErrorInfo], - ) -> Self { + pub fn new(results: Vec, engine_errors_info: &[EngineErrorInfo]) -> Self { Self { results, - page_query: page_query.to_owned(), - style: Style::default(), engine_errors_info: engine_errors_info.to_owned(), disallowed: Default::default(), filtered: Default::default(), @@ -159,21 +148,11 @@ impl SearchResults { } } - /// A setter function to add website style to the return search results. - pub fn add_style(&mut self, style: &Style) { - self.style = style.clone(); - } - /// A setter function that sets disallowed to true. pub fn set_disallowed(&mut self) { self.disallowed = true; } - /// A setter function to set the current page search query. - pub fn set_page_query(&mut self, page: &str) { - self.page_query = page.to_owned(); - } - /// A setter function that sets the filtered to true. pub fn set_filtered(&mut self) { self.filtered = true;