neon_arch commited on
Commit
a28d559
1 Parent(s): 987e667

✨ feat: add documentation for the `outputs.iter()` code block

Browse files
Files changed (1) hide show
  1. src/results/aggregator.rs +21 -0
src/results/aggregator.rs CHANGED
@@ -108,6 +108,27 @@ pub async fn aggregate(
108
 
109
  let mut engine_errors_info: Vec<EngineErrorInfo> = Vec::new();
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  let mut initial: bool = true;
112
  let mut counter: usize = 0;
113
  outputs.iter().for_each(|results| {
 
108
 
109
  let mut engine_errors_info: Vec<EngineErrorInfo> = Vec::new();
110
 
111
+ // The code block `outputs.iter()` determines whether it is the first time the code is being run.
112
+ // It does this by checking the initial flag. If it is the first time, the code selects the first
113
+ // engine from which results are fetched and adds or extends them into the `result_map`. If the
114
+ // initially selected engine fails, the code automatically selects another engine to map or extend
115
+ // into the `result_map`. On the other hand, if an engine selected for the first time successfully
116
+ // fetches results and maps them into the `result_map`, the initial flag is set to false. Subsequently,
117
+ // the code iterates through the remaining engines one by one. It compares the fetched results from each
118
+ // engine with the results already present in the `result_map` to identify any duplicates. If duplicate
119
+ // results are found, the code groups them together with the name of the engine from which they were
120
+ // fetched, and automatically removes the duplicate results from the newly fetched data.
121
+ //
122
+ // Additionally, the code handles errors returned by the engines. It keeps track of which engines
123
+ // encountered errors and stores this information in a vector of structures called `EngineErrorInfo`.
124
+ // Each structure in this vector contains the name of the engine and the type of error it returned.
125
+ // These structures will later be added to the final `SearchResults` structure. The `SearchResults`
126
+ // structure is used to display an error box in the UI containing the relevant information from
127
+ // the `EngineErrorInfo` structure.
128
+ //
129
+ // In summary, this code block manages the selection of engines, handling of duplicate results, and tracking
130
+ // of errors in order to populate the `result_map` and provide informative feedback to the user through the
131
+ // `SearchResults` structure.
132
  let mut initial: bool = true;
133
  let mut counter: usize = 0;
134
  outputs.iter().for_each(|results| {