From ff325153f06dbcb18c78a30dbf6c076996f75d7a Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Tue, 23 May 2023 00:31:46 +0000 Subject: [PATCH 1/2] add format and clippy checks to the CI jobs --- .github/workflows/rust_format.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust_format.yml b/.github/workflows/rust_format.yml index d865c8c..c300863 100644 --- a/.github/workflows/rust_format.yml +++ b/.github/workflows/rust_format.yml @@ -19,7 +19,16 @@ jobs: profile: minimal toolchain: stable components: rustfmt, clippy - + - name: Format + uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + - name: Clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-features --all-targets --all - name: Run cargo check uses: actions-rs/cargo@v1 with: From cecffe41555d76ed254ead5a7cebf277e6b98172 Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Tue, 23 May 2023 09:34:46 +0000 Subject: [PATCH 2/2] make format happy --- src/cache/mod.rs | 2 +- src/search_results_handler/aggregation_models.rs | 2 +- src/server/routes.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 91a91ca..de7dd4e 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -1 +1 @@ -pub mod cacher; +pub mod cacher; diff --git a/src/search_results_handler/aggregation_models.rs b/src/search_results_handler/aggregation_models.rs index 4fe670e..b6e6b81 100644 --- a/src/search_results_handler/aggregation_models.rs +++ b/src/search_results_handler/aggregation_models.rs @@ -116,7 +116,7 @@ impl RawSearchResult { } } -/// A named struct to store, serialize, deserialize the all the search results scraped and +/// A named struct to store, serialize, deserialize the all the search results scraped and /// aggregated from the upstream search engines. /// /// # Fields diff --git a/src/server/routes.rs b/src/server/routes.rs index ed2299f..85c522d 100644 --- a/src/server/routes.rs +++ b/src/server/routes.rs @@ -81,10 +81,10 @@ pub async fn search( .insert_header(("location", "/")) .finish()) } else { - let page_url: String; // Declare the page_url variable without initializing it + let page_url: String; // Declare the page_url variable without initializing it // ... - + let page = match params.page { Some(page_number) => { if page_number <= 1 { @@ -98,7 +98,7 @@ pub async fn search( "http://{}:{}/search?q={}&page={}", config.binding_ip_addr, config.port, query, page_number ); - + page_number } } @@ -110,11 +110,11 @@ pub async fn search( req.uri(), 1 ); - + 1 } }; - + // fetch the cached results json. let cached_results_json = redis_cache.cached_results_json(&page_url); // check if fetched results was indeed fetched or it was an error and if so