(application_id: &Uuid)
| 591 | |
| 592 | #[cfg(feature = "postgres")] |
| 593 | pub async fn get_measurement_keys(application_id: &Uuid) -> Result<Vec<String>, Error> { |
| 594 | let keys: Vec<Measurement> = diesel::sql_query( |
| 595 | r#" |
| 596 | select |
| 597 | distinct jsonb_object_keys(dp.measurements) as key |
| 598 | from |
| 599 | device_profile dp |
| 600 | inner join device d |
| 601 | on d.device_profile_id = dp.id |
| 602 | where |
| 603 | d.application_id = $1 |
| 604 | order by |
| 605 | key |
| 606 | "#, |
| 607 | ) |
| 608 | .bind::<fields::sql_types::Uuid, _>(fields::Uuid::from(application_id)) |
| 609 | .load(&mut get_async_db_conn().await?) |
| 610 | .await |
| 611 | .map_err(|e| Error::from_diesel(e, application_id.to_string()))?; |
| 612 | Ok(keys.iter().map(|k| k.key.clone()).collect()) |
| 613 | } |
| 614 | |
| 615 | #[cfg(feature = "sqlite")] |
| 616 | pub async fn get_measurement_keys(application_id: &Uuid) -> Result<Vec<String>, Error> { |
no test coverage detected