0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-25 15:38:21 -05:00

Fix page_url assignment in search route

The page_url variable in the search route was not being properly assigned in certain cases. This commit fixes the issue by ensuring that page_url is assigned the correct value based on the search parameters.

In the match expression, the conditions have been adjusted to correctly handle the page number and construct the appropriate page_url. This ensures that the generated URL for the search page is accurate and reflects the search query and page number.

This change improves the functionality and reliability of the search route by correctly setting the page_url variable based on the provided search parameters.
This commit is contained in:
MD AL AMIN TALUKDAR 2023-05-19 17:13:11 +05:30
parent feb5ea8a2e
commit 9a204b2f98

View File

@ -81,11 +81,10 @@ pub async fn search(
.insert_header(("location", "/")) .insert_header(("location", "/"))
.finish()) .finish())
} else { } else {
// Initialize the page url as an empty string let page_url: String; // Declare the page_url variable without initializing it
let mut page_url = String::new();
// ...
// Find whether the page is valid page number if not then return
// the first page number and also construct the page_url accordingly
let page = match params.page { let page = match params.page {
Some(page_number) => { Some(page_number) => {
if page_number <= 1 { if page_number <= 1 {
@ -116,6 +115,8 @@ pub async fn search(
} }
}; };
// Use the page_url variable as needed
// fetch the cached results json. // fetch the cached results json.
let cached_results_json = redis_cache.cached_results_json(&page_url); 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 // check if fetched results was indeed fetched or it was an error and if so