pub fn remove_active_transmitter(
    conn: &PgConnection,
    w_name: &str,
    range: RadioTypes,
    _logger: &Logger,
) -> Result<usize, MeshSimError> {
    use diesel::delete;
    use schema::workers;

    let rows = match range {
        RadioTypes::ShortRange => {
            use schema::active_wifi_transmitters;

            delete(active_wifi_transmitters::table)
                .filter(
                    active_wifi_transmitters::worker_id.eq_any(
                        workers::table
                            .filter(workers::worker_name.eq(w_name))
                            .select(workers::id),
                    ),
                )
                .execute(conn)
                .map_err(|e| {
                    let error_msg = String::from("Failed to remove as active wifi transmitter");
                    MeshSimError {
                        kind: MeshSimErrorKind::SQLExecutionFailure(error_msg),
                        cause: Some(Box::new(e)),
                    }
                })?
        }
        RadioTypes::LongRange => {
            use schema::active_lora_transmitters;

            delete(active_lora_transmitters::table)
                .filter(
                    active_lora_transmitters::worker_id.eq_any(
                        workers::table
                            .filter(workers::worker_name.eq(w_name))
                            .select(workers::id),
                    ),
                )
                .execute(conn)
                .map_err(|e| {
                    let error_msg = String::from("Failed to remove as active lora transmitter");
                    MeshSimError {
                        kind: MeshSimErrorKind::SQLExecutionFailure(error_msg),
                        cause: Some(Box::new(e)),
                    }
                })?
        }
    };

    Ok(rows)
}
///Remove a node from the active-transmitter list
Remove a node from the active-transmitter list
Remove a node from the active - transmitter list
pub fn remove_active_transmitter(
    conn: &PgConnection,
    w_name: &str,
    range: RadioTypes,
    _logger: &Logger,
) -> Result<usize, MeshSimError> {
    use diesel::delete;
    use schema::workers;
    let rows = match range {
        RadioTypes::ShortRange => {
            use schema::active_wifi_transmitters;
            delete(active_wifi_transmitters::table)
                .filter(
                    active_wifi_transmitters::worker_id.eq_any(
                        workers::table
                            .filter(workers::worker_name.eq(w_name))
                            .select(workers::id),
                    ),
                )
                .execute(conn)
                .map_err(|e| {
                    let error_msg = String::from("Failed to remove as active wifi transmitter");
                    MeshSimError {
                        kind: MeshSimErrorKind::SQLExecutionFailure(error_msg),
                        cause: Some(Box::new(e)),
                    }
                })?
        }
        RadioTypes::LongRange => {
            use schema::active_lora_transmitters;
            delete(active_lora_transmitters::table)
                .filter(
                    active_lora_transmitters::worker_id.eq_any(
                        workers::table
                            .filter(workers::worker_name.eq(w_name))
                            .select(workers::id),
                    ),
                )
                .execute(conn)
                .map_err(|e| {
                    let error_msg = String::from("Failed to remove as active lora transmitter");
                    MeshSimError {
                        kind: MeshSimErrorKind::SQLExecutionFailure(error_msg),
                        cause: Some(Box::new(e)),
                    }
                })?
        }
    };
    Ok(rows)
}
pub fn remove_active_transmitter ( conn : & PgConnection , w_name : & str , range : RadioTypes , _logger : & Logger , ) -> Result < usize , MeshSimError > { use diesel :: delete ; use schema :: workers ; let rows = match range { RadioTypes :: ShortRange => { use schema :: active_wifi_transmitters ; delete ( active_wifi_transmitters :: table ) . filter ( active_wifi_transmitters :: worker_id . eq_any ( workers :: table . filter ( workers :: worker_name . eq ( w_name ) ) . select ( workers :: id ) , ) , ) . execute ( conn ) . map_err ( | e | { let error_msg = String :: from ( " " ) ; MeshSimError { kind : MeshSimErrorKind :: SQLExecutionFailure ( error_msg ) , cause : Some ( Box :: new ( e ) ) , } } ) ? } RadioTypes :: LongRange => { use schema :: active_lora_transmitters ; delete ( active_lora_transmitters :: table ) . filter ( active_lora_transmitters :: worker_id . eq_any ( workers :: table . filter ( workers :: worker_name . eq ( w_name ) ) . select ( workers :: id ) , ) , ) . execute ( conn ) . map_err ( | e | { let error_msg = String :: from ( " " ) ; MeshSimError { kind : MeshSimErrorKind :: SQLExecutionFailure ( error_msg ) , cause : Some ( Box :: new ( e ) ) , } } ) ? } } ; Ok ( rows ) }
Remove a node from the active-transmitter list
Remove a node from the active - transmitter list
conn
&PgConnection
w_name
&str
range
RadioTypes
_logger
&Logger