MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / list_relays

Function list_relays

chirpstack/src/storage/relay.rs:73–108  ·  view source on GitHub ↗
(
    limit: i64,
    offset: i64,
    filters: &RelayFilters,
)

Source from the content-addressed store, hash-verified

71}
72
73pub async fn list_relays(
74 limit: i64,
75 offset: i64,
76 filters: &RelayFilters,
77) -> Result<Vec<RelayListItem>, Error> {
78 let q = device::dsl::device
79 .inner_join(device_profile::table)
80 .select((device::dev_eui, device::name));
81
82 #[cfg(feature = "postgres")]
83 let mut q = q
84 .filter(
85 dsl::sql::<sql_types::Bool>("(relay_params->'is_relay')::boolean =")
86 .bind::<sql_types::Bool, _>(true),
87 )
88 .into_boxed();
89
90 #[cfg(feature = "sqlite")]
91 let mut q = q
92 .filter(
93 dsl::sql::<sql_types::Bool>("relay_params->>'is_relay' =")
94 .bind::<sql_types::Bool, _>(true),
95 )
96 .into_boxed();
97
98 if let Some(application_id) = &filters.application_id {
99 q = q.filter(device::dsl::application_id.eq(fields::Uuid::from(application_id)));
100 }
101
102 q.order_by(device::dsl::name)
103 .limit(limit)
104 .offset(offset)
105 .load(&mut get_async_db_conn().await?)
106 .await
107 .map_err(|e| Error::from_diesel(e, "".into()))
108}
109
110pub async fn get_device_count(filters: &DeviceFilters) -> Result<i64, Error> {
111 let mut q = relay_device::dsl::relay_device

Callers 2

test_relayFunction · 0.85
listMethod · 0.85

Calls 2

get_async_db_connFunction · 0.70
intoMethod · 0.45

Tested by 1

test_relayFunction · 0.68