diff options
| author | Fuwn <[email protected]> | 2022-04-27 01:17:32 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-04-27 01:17:32 -0700 |
| commit | c81eab0c3b4fa8d8433505bd3d061f8de8e87d74 (patch) | |
| tree | 09451b5ebec415295d63504e9eaffecb37277a68 /src/modules | |
| parent | refactor(modules): move search out of module (diff) | |
| download | locus-c81eab0c3b4fa8d8433505bd3d061f8de8e87d74.tar.xz locus-c81eab0c3b4fa8d8433505bd3d061f8de8e87d74.zip | |
refactor: restrict more
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/random.rs | 2 | ||||
| -rw-r--r-- | src/modules/search.rs | 5 | ||||
| -rw-r--r-- | src/modules/sitemap.rs | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/modules/random.rs b/src/modules/random.rs index 8604d64..799376a 100644 --- a/src/modules/random.rs +++ b/src/modules/random.rs @@ -25,7 +25,7 @@ pub fn module(router: &mut windmark::Router) { "Get redirected to a random route", Box::new(|_| { windmark::Response::TemporaryRedirect( - (*crate::ROUTES.lock().unwrap()) + (*crate::route::ROUTES.lock().unwrap()) .iter() .collect::<Vec<_>>() .choose(&mut rand::thread_rng()) diff --git a/src/modules/search.rs b/src/modules/search.rs index 57f2c0c..15d0061 100644 --- a/src/modules/search.rs +++ b/src/modules/search.rs @@ -22,6 +22,7 @@ use tantivy::schema; use tempfile::TempDir; const SEARCH_INDEX_SIZE: usize = 10_000_000; +const SEARCH_SIZE: usize = 10; static INDEX_PATH: SyncLazy<Mutex<TempDir>> = SyncLazy::new(|| Mutex::new(TempDir::new().unwrap())); @@ -89,7 +90,7 @@ pub(super) fn module(router: &mut windmark::Router) { ) .parse_query(&query.0.to_string()) .unwrap(), - &tantivy::collector::TopDocs::with_limit(crate::SEARCH_SIZE), + &tantivy::collector::TopDocs::with_limit(SEARCH_SIZE), ) .unwrap(); @@ -170,7 +171,7 @@ pub fn index() { let time = tokio::time::Instant::now(); let mut new = 0; - for (route_path, information) in &(*crate::ROUTES.lock().unwrap()) { + for (route_path, information) in &(*crate::route::ROUTES.lock().unwrap()) { // Pretty inefficient, but I'll figure this out later. (*INDEX_WRITER.lock().unwrap()) .delete_all_documents() diff --git a/src/modules/sitemap.rs b/src/modules/sitemap.rs index b0a29d2..d9f94a5 100644 --- a/src/modules/sitemap.rs +++ b/src/modules/sitemap.rs @@ -25,7 +25,7 @@ pub fn module(router: &mut windmark::Router) { crate::success!( format!( "# SITEMAP\n\n{}", - (*crate::ROUTES.lock().unwrap()) + (*crate::route::ROUTES.lock().unwrap()) .iter() .map(|(r, d)| format!("=> {} {}", r, d.description)) .collect::<Vec<_>>() |