From c81eab0c3b4fa8d8433505bd3d061f8de8e87d74 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 27 Apr 2022 01:17:32 -0700 Subject: refactor: restrict more --- src/modules/random.rs | 2 +- src/modules/search.rs | 5 +++-- src/modules/sitemap.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/modules') 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::>() .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> = 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::>() -- cgit v1.2.3