Spaces:
Runtime error
Runtime error
neon_arch
commited on
Commit
•
cff7de9
1
Parent(s):
74e4fc6
✨ feat: rephrase the comment to break it into smaller sentences.
Browse files- 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 |
-
///
|
25 |
-
///
|
26 |
-
/// by matching
|
27 |
-
/// is then used to create an
|
28 |
-
/// is
|
29 |
-
///
|
30 |
-
///
|
31 |
-
///
|
32 |
-
///
|
33 |
-
///
|
34 |
-
///
|
35 |
-
///
|
|
|
|
|
|
|
|
|
|
|
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 |
///
|