create own default_destination table to remove clutter; Fixes #646
This commit is contained in:
@ -496,25 +496,6 @@ ORDER BY departure DESC
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn distances(db: &SqlitePool) -> Vec<(String, i64)> {
|
||||
let result = sqlx::query!("SELECT destination, distance_in_km FROM logbook WHERE id IN (SELECT MIN(id) FROM logbook GROUP BY destination) AND destination IS NOT NULL AND distance_in_km IS NOT NULL;")
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
result
|
||||
.into_iter()
|
||||
.filter_map(|r| {
|
||||
if let (Some(destination), Some(distance_in_km)) = (r.destination, r.distance_in_km)
|
||||
{
|
||||
Some((destination, distance_in_km))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
async fn remove_rowers(&self, db: &mut Transaction<'_, Sqlite>) {
|
||||
sqlx::query!("DELETE FROM rower WHERE logbook_id=?", self.id)
|
||||
.execute(db.deref_mut())
|
||||
@ -1071,21 +1052,6 @@ mod test {
|
||||
assert_eq!(res, Err(LogbookCreateError::TooManyRowers(1, 2)));
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_distances() {
|
||||
let pool = testdb!();
|
||||
|
||||
let res = Logbook::distances(&pool).await;
|
||||
|
||||
assert_eq!(
|
||||
res,
|
||||
vec![
|
||||
("Ottensheim".into(), 25 as i64),
|
||||
("Ottensheim + Regattastrecke".into(), 29 as i64),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_succ_home() {
|
||||
let pool = testdb!();
|
||||
|
Reference in New Issue
Block a user