add routes for different years

This commit is contained in:
2023-11-18 12:21:37 +01:00
parent e053ff96cf
commit f001aaf90f
3 changed files with 41 additions and 26 deletions

View File

@ -1,4 +1,4 @@
use chrono::NaiveDateTime;
use chrono::{Datelike, NaiveDateTime};
use rocket::FromForm;
use serde::Serialize;
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
@ -220,14 +220,14 @@ ORDER BY departure DESC
}
pub async fn completed(db: &SqlitePool) -> Vec<LogbookWithBoatAndRowers> {
let logs = sqlx::query_as!(
Logbook,
"
let year = chrono::Utc::now().year();
let logs = sqlx::query_as(
&format!("
SELECT id, boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
FROM logbook
WHERE arrival is not null
WHERE arrival is not null AND arrival LIKE '{}-%'
ORDER BY departure DESC
"
", year)
)
.fetch_all(db)
.await