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

Function list_deployments

chirpstack/src/storage/fuota.rs:326–396  ·  view source on GitHub ↗
(
    user_id: Option<Uuid>,
    tenant_id: Option<Uuid>,
    application_id: Option<Uuid>,
    limit: i64,
    offset: i64,
)

Source from the content-addressed store, hash-verified

324}
325
326pub async fn list_deployments(
327 user_id: Option<Uuid>,
328 tenant_id: Option<Uuid>,
329 application_id: Option<Uuid>,
330 limit: i64,
331 offset: i64,
332) -> Result<Vec<FuotaDeploymentListItem>, Error> {
333 let mut q = fuota_deployment::dsl::fuota_deployment
334 .inner_join(application::table)
335 .select((
336 fuota_deployment::id,
337 fuota_deployment::created_at,
338 fuota_deployment::updated_at,
339 fuota_deployment::started_at,
340 fuota_deployment::completed_at,
341 fuota_deployment::name,
342 application::id,
343 application::name,
344 ))
345 .into_boxed();
346
347 // filter by user permissions
348 if let Some(user_id) = user_id {
349 q = q.filter(dsl::exists(
350 user::table
351 .filter(
352 user::id
353 .eq(fields::Uuid::from(user_id))
354 .and(user::is_active.eq(true)),
355 )
356 .filter(
357 user::is_admin.eq(true).or(dsl::exists(
358 tenant_user::table
359 .filter(
360 tenant_user::user_id
361 .eq(user::id)
362 .and(tenant_user::tenant_id.eq(application::tenant_id)),
363 )
364 .filter(
365 tenant_user::is_admin
366 .eq(true)
367 .or(tenant_user::is_device_admin.eq(true))
368 .or(dsl::exists(
369 tenant_user_application::table.filter(
370 tenant_user_application::user_id.eq(user::id).and(
371 tenant_user_application::application_id
372 .eq(application::id),
373 ),
374 ),
375 )),
376 ),
377 )),
378 ),
379 ));
380 }
381
382 if let Some(tenant_id) = tenant_id {
383 q = q.filter(application::tenant_id.eq(fields::Uuid::from(tenant_id)));

Callers 1

list_deploymentsMethod · 0.85

Calls 2

get_async_db_connFunction · 0.70
intoMethod · 0.45

Tested by

no test coverage detected