neon_arch commited on
Commit
cff7de9
1 Parent(s): 74e4fc6

✨ feat: rephrase the comment to break it into smaller sentences.

Browse files
Files changed (1) hide show
  1. src/results/aggregator.rs +17 -12
src/results/aggregator.rs CHANGED
@@ -21,18 +21,23 @@ use crate::engines::{
21
  /// Aliases for long type annotations
22
  type FutureVec = Vec<JoinHandle<Result<HashMap<String, RawSearchResult>, Report<EngineError>>>>;
23
 
24
- /// A function that aggregates all the scraped results from the above user selected upstream
25
- /// search engines either selected from the UI or from the config file which is handled by the code
26
- /// by matching over the selected search engines and adding the selected ones to the vector which
27
- /// is then used to create an async task vector with `tokio::spawn` which returns a future which
28
- /// is then awaited on in another loop and then all the collected results is filtered for errors
29
- /// and proper results and if an error is found is then sent to the UI with the engine name and the
30
- /// error type that caused it by putting them finallt in the returned `SearchResults` struct. Also
31
- /// the same process also removes duplicate results and if two results are found to be from two or
32
- /// more engines then puts their names together to show the results are fetched from these upstream
33
- /// engines and then removes all data from the HashMap and puts into a struct of all results aggregated
34
- /// into a vector and also adds the query used into the struct this is neccessory because otherwise the
35
- /// search bar in search remains empty if searched from the query url.
 
 
 
 
 
36
  ///
37
  /// # Example:
38
  ///
 
21
  /// Aliases for long type annotations
22
  type FutureVec = Vec<JoinHandle<Result<HashMap<String, RawSearchResult>, Report<EngineError>>>>;
23
 
24
+ /// The function aggregates the scraped results from the user-selected upstream search engines.
25
+ /// These engines can be chosen either from the user interface (UI) or from the configuration file.
26
+ /// The code handles this process by matching the selected search engines and adding them to a vector.
27
+ /// This vector is then used to create an asynchronous task vector using `tokio::spawn`, which returns
28
+ /// a future. This future is awaited in another loop. Once the results are collected, they are filtered
29
+ /// to remove any errors and ensure only proper results are included. If an error is encountered, it is
30
+ /// sent to the UI along with the name of the engine and the type of error. This information is finally
31
+ /// placed in the returned `SearchResults` struct.
32
+ ///
33
+ /// Additionally, the function eliminates duplicate results. If two results are identified as coming from
34
+ /// multiple engines, their names are combined to indicate that the results were fetched from these upstream
35
+ /// engines. After this, all the data in the `HashMap` is removed and placed into a struct that contains all
36
+ /// the aggregated results in a vector. Furthermore, the query used is also added to the struct. This step is
37
+ /// necessary to ensure that the search bar in the search remains populated even when searched from the query URL.
38
+ ///
39
+ /// Overall, this function serves to aggregate scraped results from user-selected search engines, handling errors,
40
+ /// removing duplicates, and organizing the data for display in the UI.
41
  ///
42
  /// # Example:
43
  ///