feat(db): device_readings 新增 metric 字段用于多行拆分存储
This commit is contained in:
@@ -11,6 +11,8 @@ pub struct Model {
|
||||
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
||||
pub device_id: Option<String>,
|
||||
pub device_type: String,
|
||||
#[sea_orm(nullable)]
|
||||
pub metric: Option<String>,
|
||||
#[sea_orm(skip_serializing_if = "Option::is_none")]
|
||||
pub device_model: Option<String>,
|
||||
pub raw_value: serde_json::Value,
|
||||
|
||||
@@ -207,6 +207,7 @@ async fn batch_insert_readings(
|
||||
patient_id: Set(patient_id),
|
||||
device_id: Set(Some(device_id.to_string())),
|
||||
device_type: Set(r.device_type.clone()),
|
||||
metric: Set(r.values.get("metric").and_then(|v| v.as_str()).map(String::from)),
|
||||
device_model: Set(device_model.map(String::from)),
|
||||
raw_value: Set(r.values.clone()),
|
||||
measured_at: Set(*measured_at),
|
||||
|
||||
Reference in New Issue
Block a user