hotfix datasource id ref

This commit is contained in:
dal 2025-05-01 10:06:14 -06:00
parent 716feb4115
commit 3b599508a3
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
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; let sql = metric_yml.sql;
// --- USE DIRECT DATA SOURCE ID --- // --- USE DIRECT DATA SOURCE ID ---
let data_source_id = match Uuid::parse_str(&metric.data_source_id) { let data_source_id = metric.data_source_id; // Already a Uuid
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"));
}
};
tracing::debug!(metric_id = %request.metric_id, data_source_id = %data_source_id, "Using direct data source ID from metric"); tracing::debug!(metric_id = %request.metric_id, data_source_id = %data_source_id, "Using direct data source ID from metric");
tracing::info!( 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) // Get dataset information for the resolved dataset IDs (using the fetched IDs)
let mut datasets = Vec::new(); let mut datasets = Vec::new();
let mut first_data_source_id = None;
if !resolved_dataset_ids.is_empty() { if !resolved_dataset_ids.is_empty() {
// Fetch only if there are IDs to prevent unnecessary query // Fetch only if there are IDs to prevent unnecessary query
let dataset_infos = datasets::table let dataset_infos = datasets::table
@ -187,9 +186,6 @@ pub async fn get_metric_for_dashboard_handler(
id: dataset_info.id.to_string(), id: dataset_info.id.to_string(),
name: dataset_info.name, 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, file_name: metric_file.file_name,
time_frame: resolved_time_frame, time_frame: resolved_time_frame,
datasets, 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 error: None, // Assume ok
chart_config: Some(resolved_chart_config), chart_config: Some(resolved_chart_config),
data_metadata, data_metadata,

View File

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

View File

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