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

Function get_count

chirpstack/src/storage/gateway.rs:293–323  ·  view source on GitHub ↗
(filters: &Filters)

Source from the content-addressed store, hash-verified

291}
292
293pub async fn get_count(filters: &Filters) -> Result<i64, Error> {
294 let mut q = gateway::dsl::gateway
295 .select(dsl::count_star())
296 .distinct()
297 .left_join(multicast_group_gateway::table)
298 .into_boxed();
299
300 if let Some(tenant_id) = &filters.tenant_id {
301 q = q.filter(gateway::dsl::tenant_id.eq(fields::Uuid::from(tenant_id)));
302 }
303
304 if let Some(multicast_group_id) = &filters.multicast_group_id {
305 q = q.filter(
306 multicast_group_gateway::dsl::multicast_group_id
307 .eq(fields::Uuid::from(multicast_group_id)),
308 );
309 }
310
311 if let Some(search) = &filters.search {
312 #[cfg(feature = "postgres")]
313 {
314 q = q.filter(gateway::dsl::name.ilike(format!("%{}%", search)));
315 }
316 #[cfg(feature = "sqlite")]
317 {
318 q = q.filter(gateway::dsl::name.like(format!("%{}%", search)));
319 }
320 }
321
322 Ok(q.first(&mut get_async_db_conn().await?).await?)
323}
324
325pub async fn list(
326 limit: i64,

Callers 1

test_gatewayFunction · 0.70

Calls 1

get_async_db_connFunction · 0.70

Tested by 1

test_gatewayFunction · 0.56