add routes for different years
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user