Compare commits
No commits in common. "f574ae14db79632e84de659379a220160f815820" and "e33074f5403f1245dc5db8c9e0ad9883cf6f6d87" have entirely different histories.
f574ae14db
...
e33074f540
@ -210,11 +210,9 @@ async fn new_thirty(
|
|||||||
eprintln!("Failed to persist file: {:?}", e);
|
eprintln!("Failed to persist file: {:?}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = data.result.trim_start_matches(|c| c == '0' || c == ' ');
|
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"UPDATE user SET dirty_thirty = ? where id = ?",
|
"UPDATE user SET dirty_thirty = ? where id = ?",
|
||||||
result,
|
data.result,
|
||||||
data.user
|
data.user
|
||||||
)
|
)
|
||||||
.execute(db.inner())
|
.execute(db.inner())
|
||||||
@ -233,32 +231,6 @@ async fn new_thirty(
|
|||||||
Flash::success(Redirect::to("/ergo"), "Erfolgreich eingetragen")
|
Flash::success(Redirect::to("/ergo"), "Erfolgreich eingetragen")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_time(input: &str) -> String {
|
|
||||||
let mut parts: Vec<&str> = input.split(':').collect();
|
|
||||||
|
|
||||||
// If there's only seconds (e.g., "24.2"), treat it as "00:00:24.2"
|
|
||||||
if parts.len() == 1 {
|
|
||||||
parts.insert(0, "0"); // Add "0" for hours
|
|
||||||
parts.insert(0, "0"); // Add "0" for minutes
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there are two parts (e.g., "4:24.2"), treat it as "00:04:24.2"
|
|
||||||
if parts.len() == 2 {
|
|
||||||
parts.insert(0, "0"); // Add "0" for hours
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now parts should have [hours, minutes, seconds]
|
|
||||||
let hours = if parts[0].len() == 1 { format!("0{}", parts[0]) } else { parts[0].to_string() };
|
|
||||||
let minutes = if parts[1].len() == 1 { format!("0{}", parts[1]) } else { parts[1].to_string() };
|
|
||||||
let seconds = parts[2];
|
|
||||||
|
|
||||||
// Split seconds into whole and fractional parts
|
|
||||||
let (sec_int, sec_frac) = seconds.split_once('.').unwrap_or((seconds, "0"));
|
|
||||||
|
|
||||||
// Format the time as "hh:mm:ss.s"
|
|
||||||
format!("{}:{}:{}.{:1}", hours, minutes, sec_int, sec_frac.chars().next().unwrap_or('0'))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[post("/dozen", data = "<data>", format = "multipart/form-data")]
|
#[post("/dozen", data = "<data>", format = "multipart/form-data")]
|
||||||
async fn new_dozen(
|
async fn new_dozen(
|
||||||
db: &State<SqlitePool>,
|
db: &State<SqlitePool>,
|
||||||
@ -281,12 +253,10 @@ async fn new_dozen(
|
|||||||
if let Err(e) = data.proof.move_copy_to(file_path).await {
|
if let Err(e) = data.proof.move_copy_to(file_path).await {
|
||||||
eprintln!("Failed to persist file: {:?}", e);
|
eprintln!("Failed to persist file: {:?}", e);
|
||||||
}
|
}
|
||||||
let result = data.result.trim_start_matches(|c| c == '0' || c == ' ');
|
|
||||||
let result = format_time(result);
|
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"UPDATE user SET dirty_dozen = ? where id = ?",
|
"UPDATE user SET dirty_dozen = ? where id = ?",
|
||||||
result,
|
data.result,
|
||||||
data.user
|
data.user
|
||||||
)
|
)
|
||||||
.execute(db.inner())
|
.execute(db.inner())
|
||||||
|
Loading…
Reference in New Issue
Block a user