about summary refs log tree commit diff
path: root/indexer/src/main.rs
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-11-04 15:44:59 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-11-04 15:44:59 +0100
commit09b038e8da139fe306abdf6592a8fa83c0892eaa (patch)
tree582c1c6d6535965713e2343090fcda443f062b12 /indexer/src/main.rs
parentIndexer: Add missing /search/ route (diff)
downloadOSSE-09b038e8da139fe306abdf6592a8fa83c0892eaa.tar.gz
OSSE-09b038e8da139fe306abdf6592a8fa83c0892eaa.tar.bz2
OSSE-09b038e8da139fe306abdf6592a8fa83c0892eaa.zip
Indexer: Make & implement the trait insert() taking a [word] for insert
This has the advantage of taking less calls to the insert() and being
able to add all the logic previous to inertion to the actual Indexer
implementation.
Diffstat (limited to 'indexer/src/main.rs')
-rw-r--r--indexer/src/main.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/indexer/src/main.rs b/indexer/src/main.rs
index 51a0e20..dcb4b9a 100644
--- a/indexer/src/main.rs
+++ b/indexer/src/main.rs
@@ -12,12 +12,11 @@ pub trait Indexer {
     //too many args?
     fn insert(
         &mut self,
-        word: &str,
+        words: &[String],
         url: &str,
         title: Option<String>,
         description: Option<String>,
         content: &str,
-        fixed_words: &[String],
     ) -> Result<(), String>;
     fn search(&self, term: &str) -> Result<HashSet<IndexedResource>, String>;
     fn num_of_words(&self) -> usize;
@@ -112,16 +111,13 @@ async fn add_resource(
 
     //and for each changed content word we add it to the db (word -> list.append(url))
     let mut indexer = data.indexer.lock().unwrap();
-    for word in &fixed_words {
-        let _ = indexer.insert(
-            word,
-            &resource.url,
-            page_title.clone(),
-            page_description.clone(),
-            &resource.content,
-            &fixed_words,
-        );
-    }
+    let _ = indexer.insert(
+        &fixed_words,
+        &resource.url,
+        page_title.clone(),
+        page_description.clone(),
+        &resource.content,
+    );
 
     //TODO: ADD LANG? EN in meta tag (frontend)