Revert sorting in search field and update database connection

This commit is contained in:
Knyffen 2024-08-21 22:27:00 +02:00
parent 2b7c64b2e8
commit d05067b553
3 changed files with 9 additions and 7 deletions

Binary file not shown.

View File

@ -418,7 +418,7 @@ fn filter_search_options() {
.collect();
let mut search_res = parser.match_list(search_option_map.keys(), &mut matcher);
search_res.sort_unstable_by_key(|x| (x.1, x.0));
search_res.sort_unstable_by_key(|x| std::cmp::Reverse((x.1, x.0)));
// Note that this way the children are sorted the same order as search_res
let shown_children: Vec<HtmlElement> = search_res

View File

@ -36,11 +36,12 @@ struct AppState {
fn get_sql_pool(url: &str) -> Pool {
loop {
let sql_pool_attempt = Pool::new(url);
if let Ok(sql_pool) = sql_pool_attempt {
return sql_pool;
} else {
println!("Cannot connect to SQL database. Retrying");
thread::sleep(time::Duration::from_millis(1000));
match sql_pool_attempt {
Ok(sql_pool) => return sql_pool,
Err(e) => {
println!("Cannot connect to SQL database. Retrying. {:?}", e);
thread::sleep(time::Duration::from_millis(1000));
}
}
}
}
@ -48,7 +49,8 @@ fn get_sql_pool(url: &str) -> Pool {
#[tokio::main]
async fn main() {
//Initialize state
let sql_pool = get_sql_pool("mysql://root:hQqjjMa3JbpLrJvJo7FV@db.knyffen.dk:3306/Food");
let sql_pool =
get_sql_pool("mysql://calories_user:I96xkFy0UFPbB0JCP6X6@db.knyffen.dk:3306/Food");
let shared_state = Arc::new(AppState { sql_pool });
// build our application with a single route