A bit of clean up

This commit is contained in:
Greg Burri 2025-03-02 00:39:58 +01:00
parent cb2483eab1
commit a590d7e1e9
24 changed files with 259 additions and 237 deletions

View file

@ -22,10 +22,10 @@ impl Connection {
if let Some(user_id) = user_id {
sqlx::query_as(
r#"
SELECT [id], [title]
FROM [Recipe]
WHERE [is_published] = true AND ([lang] = $1 OR [user_id] = $2)
ORDER BY [title] COLLATE NOCASE
SELECT [id], [title]
FROM [Recipe]
WHERE [is_published] = true AND ([lang] = $1 OR [user_id] = $2)
ORDER BY [title] COLLATE NOCASE
"#,
)
.bind(lang)
@ -33,10 +33,10 @@ impl Connection {
} else {
sqlx::query_as(
r#"
SELECT [id], [title]
FROM [Recipe]
WHERE [is_published] = true AND [lang] = $1
ORDER BY [title] COLLATE NOCASE
SELECT [id], [title]
FROM [Recipe]
WHERE [is_published] = true AND [lang] = $1
ORDER BY [title] COLLATE NOCASE
"#,
)
.bind(lang)

View file

@ -1,12 +1,12 @@
use std::{net::SocketAddr, path::Path};
use axum::{
Router,
extract::{ConnectInfo, Extension, FromRef, Request, State},
http::StatusCode,
middleware::{self, Next},
response::Response,
routing::{delete, get, post, put},
Router,
};
use axum_extra::extract::cookie::CookieJar;
use chrono::prelude::*;
@ -14,7 +14,7 @@ use clap::Parser;
use config::Config;
use itertools::Itertools;
use tower_http::{services::ServeDir, trace::TraceLayer};
use tracing::{event, Level};
use tracing::{Level, event};
use data::{db, model};
use translation::Tr;
@ -380,11 +380,7 @@ async fn process_args() -> bool {
let db_path_bckup = (1..)
.find_map(|n| {
let p = db_path.with_extension(format!("sqlite.bckup{:03}", n));
if p.exists() {
None
} else {
Some(p)
}
if p.exists() { None } else { Some(p) }
})
.unwrap();
std::fs::copy(&db_path, &db_path_bckup).unwrap_or_else(|error| {

View file

@ -1,31 +1,32 @@
use std::{collections::HashMap, net::SocketAddr};
use axum::{
Form,
body::Body,
debug_handler,
extract::{ConnectInfo, Extension, Request, State},
http::HeaderMap,
response::{Html, IntoResponse, Redirect, Response},
Form,
};
use axum_extra::extract::{
cookie::{Cookie, CookieJar},
Host, Query,
cookie::{Cookie, CookieJar},
};
use chrono::Duration;
use lettre::Address;
use rinja::Template;
use serde::Deserialize;
use tracing::{event, Level};
use tracing::{Level, event};
use crate::{
AppState, Result,
config::Config,
consts,
data::{db, model},
email,
html_templates::*,
translation::{self, Sentence},
utils, AppState, Result,
utils,
};
/// SIGN UP ///
@ -807,7 +808,7 @@ pub async fn edit_user_post(
message = tr.t(Sentence::ProfileSaved);
}
Err(_) => {
return error_response(ProfileUpdateError::DatabaseError, &form_data, user, tr)
return error_response(ProfileUpdateError::DatabaseError, &form_data, user, tr);
}
}