pub fn update_worker_target(
    conn: &PgConnection,
    dest: Position,
    id: i32,
    _logger: &Logger,
) -> Result<usize, MeshSimError> {
    use schema::worker_destinations::{self, *};

    let new_dest = NewDest {
        worker_id: id,
        x: dest.x,
        y: dest.y,
    };
    let rows = diesel::insert_into(worker_destinations::table)
        .values(&new_dest)
        .on_conflict(worker_id)
        .do_update()
        .set(&new_dest)
        .execute(conn)
        .map_err(|e| {
            let error_msg = String::from("Failed to insert/update worker destination");
            MeshSimError {
                kind: MeshSimErrorKind::SQLExecutionFailure(error_msg),
                cause: Some(Box::new(e)),
            }
        })?;
    Ok(rows)
}
/// Create a new target position for a worker
Create a new target position for a worker
Create a new target position for a worker
pub fn update_worker_target(
    conn: &PgConnection,
    dest: Position,
    id: i32,
    _logger: &Logger,
) -> Result<usize, MeshSimError> {
    use schema::worker_destinations::{self, *};
    let new_dest = NewDest {
        worker_id: id,
        x: dest.x,
        y: dest.y,
    };
    let rows = diesel::insert_into(worker_destinations::table)
        .values(&new_dest)
        .on_conflict(worker_id)
        .do_update()
        .set(&new_dest)
        .execute(conn)
        .map_err(|e| {
            let error_msg = String::from("Failed to insert/update worker destination");
            MeshSimError {
                kind: MeshSimErrorKind::SQLExecutionFailure(error_msg),
                cause: Some(Box::new(e)),
            }
        })?;
    Ok(rows)
}
pub fn update_worker_target ( conn : & PgConnection , dest : Position , id : i32 , _logger : & Logger , ) -> Result < usize , MeshSimError > { use schema :: worker_destinations :: { self , * } ; let new_dest = NewDest { worker_id : id , x : dest . x , y : dest . y , } ; let rows = diesel :: insert_into ( worker_destinations :: table ) . values ( & new_dest ) . on_conflict ( worker_id ) . do_update ( ) . set ( & new_dest ) . execute ( conn ) . map_err ( | e | { let error_msg = String :: from ( " " ) ; MeshSimError { kind : MeshSimErrorKind :: SQLExecutionFailure ( error_msg ) , cause : Some ( Box :: new ( e ) ) , } } ) ? ; Ok ( rows ) }
Create a new target position for a worker
Create a new target position for a worker
conn
&PgConnection
dest
Position
id
i32
_logger
&Logger