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

Function get_relay_count

chirpstack/src/storage/relay.rs:45–71  ·  view source on GitHub ↗
(filters: &RelayFilters)

Source from the content-addressed store, hash-verified

43}
44
45pub async fn get_relay_count(filters: &RelayFilters) -> Result<i64, Error> {
46 let q = device::dsl::device
47 .select(dsl::count_star())
48 .inner_join(device_profile::table);
49
50 #[cfg(feature = "postgres")]
51 let mut q = q
52 .filter(
53 dsl::sql::<sql_types::Bool>("(relay_params->'is_relay')::boolean =")
54 .bind::<sql_types::Bool, _>(true),
55 )
56 .into_boxed();
57
58 #[cfg(feature = "sqlite")]
59 let mut q = q
60 .filter(
61 dsl::sql::<sql_types::Bool>("relay_params->>'is_relay' =")
62 .bind::<sql_types::Bool, _>(true),
63 )
64 .into_boxed();
65
66 if let Some(application_id) = &filters.application_id {
67 q = q.filter(device::dsl::application_id.eq(fields::Uuid::from(application_id)));
68 }
69
70 Ok(q.first(&mut get_async_db_conn().await?).await?)
71}
72
73pub async fn list_relays(
74 limit: i64,

Callers 2

test_relayFunction · 0.85
listMethod · 0.85

Calls 1

get_async_db_connFunction · 0.70

Tested by 1

test_relayFunction · 0.68