Merge pull request #250 from buster-so/staging

hotfix datasource id ref
This commit is contained in:
dal 2025-05-01 09:06:36 -07:00 committed by GitHub
commit 1e321cfa3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 24 deletions

View File

@ -146,17 +146,7 @@ pub async fn get_metric_data_handler(
let sql = metric_yml.sql;
// --- USE DIRECT DATA SOURCE ID ---
let data_source_id = match Uuid::parse_str(&metric.data_source_id) {
Ok(id) => id,
Err(_) => {
tracing::error!(
"Invalid data_source_id format ({}) found for metric {}",
metric.data_source_id,
request.metric_id
);
return Err(anyhow!("Invalid data source ID associated with the metric"));
}
};
let data_source_id = metric.data_source_id; // Already a Uuid
tracing::debug!(metric_id = %request.metric_id, data_source_id = %data_source_id, "Using direct data source ID from metric");
tracing::info!(

View File

@ -168,7 +168,6 @@ pub async fn get_metric_for_dashboard_handler(
// Get dataset information for the resolved dataset IDs (using the fetched IDs)
let mut datasets = Vec::new();
let mut first_data_source_id = None;
if !resolved_dataset_ids.is_empty() {
// Fetch only if there are IDs to prevent unnecessary query
let dataset_infos = datasets::table
@ -187,9 +186,6 @@ pub async fn get_metric_for_dashboard_handler(
id: dataset_info.id.to_string(),
name: dataset_info.name,
});
if first_data_source_id.is_none() {
first_data_source_id = Some(dataset_info.data_source_id);
}
}
}
@ -278,7 +274,7 @@ pub async fn get_metric_for_dashboard_handler(
file_name: metric_file.file_name,
time_frame: resolved_time_frame,
datasets,
data_source_id: first_data_source_id.map_or("".to_string(), |id| id.to_string()),
data_source_id: metric_file.data_source_id, // Use canonical Uuid from main record
error: None, // Assume ok
chart_config: Some(resolved_chart_config),
data_metadata,

View File

@ -286,7 +286,6 @@ pub async fn get_metric_handler(
// Get dataset information for the resolved dataset IDs
let mut datasets = Vec::new();
let mut first_data_source_id = None;
// Fetch datasets based on the resolved_dataset_ids fetched above
if !resolved_dataset_ids.is_empty() {
let dataset_infos = datasets::table
@ -305,9 +304,6 @@ pub async fn get_metric_handler(
id: dataset_info.id.to_string(),
name: dataset_info.name,
});
if first_data_source_id.is_none() {
first_data_source_id = Some(dataset_info.data_source_id);
}
}
}
@ -420,8 +416,8 @@ pub async fn get_metric_handler(
description: resolved_description, // Use resolved description
file_name: metric_file.file_name, // Not versioned
time_frame: resolved_time_frame, // Use resolved time frame
datasets, // Fetched based on resolved_dataset_ids
data_source_id: first_data_source_id.map_or("".to_string(), |id| id.to_string()), // Based on resolved datasets
datasets, // Fetched based on resolved_dataset_ids (for display purposes only)
data_source_id: metric_file.data_source_id, // Use canonical ID (Uuid) from main record
error: None, // Assume ok
chart_config: Some(resolved_chart_config), // Use resolved chart config
data_metadata, // Not versioned

View File

@ -3,6 +3,8 @@ use database::{enums::{AssetPermissionRole, Verification}, types::{ChartConfig,
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use std::collections::HashMap;
use diesel::Selectable;
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Dataset {
@ -34,8 +36,8 @@ pub struct BusterMetric {
pub file_name: String,
pub time_frame: String,
pub datasets: Vec<Dataset>,
pub data_source_id: String,
pub error: Option<String>,
pub data_source_id: Uuid,
pub error: Option<Value>,
pub chart_config: Option<ChartConfig>, // BusterChartConfigProps
pub data_metadata: Option<DataMetadata>,
pub status: Verification,