Remove from_ref with unneeded clones

This commit is contained in:
Tobias Reisinger 2023-11-26 23:27:15 +01:00
parent 734f8b291c
commit 76b14ce75b
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
3 changed files with 4 additions and 12 deletions

View file

@ -22,7 +22,7 @@ pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, ApiErr
let relays = Relay::get_all(&mut pool_conn).await?; let relays = Relay::get_all(&mut pool_conn).await?;
let return_relays: Vec<ReturnRelay> = let return_relays: Vec<ReturnRelay> =
relays.iter().map(|s| ReturnRelay::from_relay_ref(s, &mut pool_conn)).collect(); relays.into_iter().map(|s| ReturnRelay::from_relay(s, &mut pool_conn)).collect();
Ok(HttpResponse::Ok().json(return_relays)) Ok(HttpResponse::Ok().json(return_relays))
} }
@ -40,7 +40,7 @@ pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, ApiErr
// let relays = Relay::get_by_tag(&mut pool_conn, &tag_db).await?; // let relays = Relay::get_by_tag(&mut pool_conn, &tag_db).await?;
// //
// let return_relays: Vec<ReturnRelay> = // let return_relays: Vec<ReturnRelay> =
// relays.iter().map(|s| ReturnRelay::from_relay_ref(s, &mut pool_conn)).collect(); // relays.into_iter().map(|s| ReturnRelay::from_relay(s, &mut pool_conn)).collect();
// //
// Ok(HttpResponse::Ok().json(return_relays)) // Ok(HttpResponse::Ok().json(return_relays))
//} //}

View file

@ -24,7 +24,7 @@ pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, ApiErr
let schedules = Schedule::get_all(&mut pool_conn).await?; let schedules = Schedule::get_all(&mut pool_conn).await?;
let return_schedules: Vec<ReturnSchedule> = let return_schedules: Vec<ReturnSchedule> =
schedules.iter().map(|s| ReturnSchedule::from_schedule_ref(s, &mut pool_conn)).collect(); schedules.into_iter().map(|s| ReturnSchedule::from_schedule(s, &mut pool_conn)).collect();
Ok(HttpResponse::Ok().json(return_schedules)) Ok(HttpResponse::Ok().json(return_schedules))
} }
@ -42,7 +42,7 @@ pub async fn tagged(
let schedules = Schedule::get_by_tag(&mut pool_conn, &tag_db).await?; let schedules = Schedule::get_by_tag(&mut pool_conn, &tag_db).await?;
let return_schedules: Vec<ReturnSchedule> = let return_schedules: Vec<ReturnSchedule> =
schedules.iter().map(|s| ReturnSchedule::from_schedule_ref(s, &mut pool_conn)).collect(); schedules.into_iter().map(|s| ReturnSchedule::from_schedule(s, &mut pool_conn)).collect();
Ok(HttpResponse::Ok().json(return_schedules)) Ok(HttpResponse::Ok().json(return_schedules))
} }

View file

@ -22,10 +22,6 @@ impl ReturnSchedule {
tags, tags,
} }
} }
pub fn from_schedule_ref(schedule: &Schedule, conn: &mut PoolConnection<Sqlite>) -> Self {
Self::from_schedule(schedule.clone(), conn)
}
} }
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
@ -51,8 +47,4 @@ impl ReturnRelay {
tags, tags,
} }
} }
pub fn from_relay_ref(relay: &Relay, conn: &mut PoolConnection<Sqlite>) -> Self {
Self::from_relay(relay.clone(), conn)
}
} }