From 1513a39268471ee9060f1e279341aa7b80367612 Mon Sep 17 00:00:00 2001 From: dal Date: Fri, 21 Mar 2025 10:44:53 -0600 Subject: [PATCH] clean up --- api/libs/agents/src/agent.rs | 4 ++-- .../agents/src/tools/categories/file_tools/common.rs | 4 ++-- .../src/tools/categories/file_tools/create_dashboards.rs | 2 +- .../src/tools/categories/file_tools/modify_dashboards.rs | 2 +- .../src/tools/categories/file_tools/modify_metrics.rs | 9 +++------ .../handlers/src/chats/sharing/create_sharing_handler.rs | 2 +- .../handlers/src/chats/sharing/list_sharing_handler.rs | 2 +- .../src/collections/add_assets_to_collection_handler.rs | 4 ++-- .../collections/add_dashboards_to_collection_handler.rs | 6 +++--- .../remove_metrics_from_collection_handler.rs | 6 +++--- .../src/collections/update_collection_handler.rs | 2 +- .../handlers/src/dashboards/create_dashboard_handler.rs | 4 ++-- .../src/dashboards/sharing/create_sharing_handler.rs | 6 +++--- .../src/metrics/add_metric_to_collections_handler.rs | 6 +++--- api/libs/handlers/src/metrics/delete_metric_handler.rs | 6 +++--- .../src/metrics/post_metric_dashboard_handler.rs | 6 +++--- .../src/metrics/sharing/delete_sharing_handler.rs | 2 +- .../handlers/tests/metrics/post_metric_dashboard_test.rs | 4 ++-- api/libs/handlers/tests/metrics/update_metric_test.rs | 1 - api/libs/sharing/src/check_asset_permission.rs | 6 +++--- api/libs/sharing/src/create_asset_permission.rs | 4 ++-- api/libs/sharing/src/remove_asset_permissions.rs | 2 +- 22 files changed, 43 insertions(+), 47 deletions(-) diff --git a/api/libs/agents/src/agent.rs b/api/libs/agents/src/agent.rs index f4778769a..e709b2cfc 100644 --- a/api/libs/agents/src/agent.rs +++ b/api/libs/agents/src/agent.rs @@ -1100,7 +1100,7 @@ mod tests { setup(); // Create agent first - let mut agent = Agent::new( + let agent = Agent::new( "o1".to_string(), HashMap::new(), Uuid::new_v4(), @@ -1133,7 +1133,7 @@ mod tests { setup(); // Create LLM client and agent - let mut agent = Agent::new( + let agent = Agent::new( "o1".to_string(), HashMap::new(), Uuid::new_v4(), diff --git a/api/libs/agents/src/tools/categories/file_tools/common.rs b/api/libs/agents/src/tools/categories/file_tools/common.rs index 23f5f8210..1337dcaf5 100644 --- a/api/libs/agents/src/tools/categories/file_tools/common.rs +++ b/api/libs/agents/src/tools/categories/file_tools/common.rs @@ -1058,9 +1058,9 @@ mod tests { use chrono::Utc; use database::{ models::DashboardFile, - types::{DashboardYml, Version}, + types::DashboardYml, }; - use serde_json::json; + use uuid::Uuid; // Mock functions for testing diff --git a/api/libs/agents/src/tools/categories/file_tools/create_dashboards.rs b/api/libs/agents/src/tools/categories/file_tools/create_dashboards.rs index 217f11670..10b4b6569 100644 --- a/api/libs/agents/src/tools/categories/file_tools/create_dashboards.rs +++ b/api/libs/agents/src/tools/categories/file_tools/create_dashboards.rs @@ -15,7 +15,7 @@ use database::{ use diesel::insert_into; use diesel_async::RunQueryDsl; use serde::{Deserialize, Serialize}; -use serde_json::{self, json, Value}; +use serde_json::{self, Value}; use tracing::debug; use uuid::Uuid; diff --git a/api/libs/agents/src/tools/categories/file_tools/modify_dashboards.rs b/api/libs/agents/src/tools/categories/file_tools/modify_dashboards.rs index 1a83e2b69..f0df48819 100644 --- a/api/libs/agents/src/tools/categories/file_tools/modify_dashboards.rs +++ b/api/libs/agents/src/tools/categories/file_tools/modify_dashboards.rs @@ -16,7 +16,7 @@ use tracing::{debug, error, info}; use super::{ common::{ - apply_modifications_to_content, FileModificationBatch, ModificationResult, + ModificationResult, ModifyFilesOutput, ModifyFilesParams, process_dashboard_file_modification, }, file_types::file::FileWithId, diff --git a/api/libs/agents/src/tools/categories/file_tools/modify_metrics.rs b/api/libs/agents/src/tools/categories/file_tools/modify_metrics.rs index 8e65c8596..83d538900 100644 --- a/api/libs/agents/src/tools/categories/file_tools/modify_metrics.rs +++ b/api/libs/agents/src/tools/categories/file_tools/modify_metrics.rs @@ -3,24 +3,21 @@ use std::{env, sync::Arc, time::Instant}; use anyhow::Result; use async_trait::async_trait; use braintrust::{get_prompt_system_message, BraintrustClient}; -use chrono::Utc; use database::{ - enums::Verification, models::MetricFile, pool::get_pg_pool, schema::metric_files, + models::MetricFile, pool::get_pg_pool, schema::metric_files, types::MetricYml, }; use diesel::{upsert::excluded, ExpressionMethods, QueryDsl}; use diesel_async::RunQueryDsl; use indexmap::IndexMap; use query_engine::data_types::DataType; -use serde::{Deserialize, Serialize}; use serde_json::Value; use tracing::{debug, error, info}; use uuid::Uuid; use super::{ common::{ - apply_modifications_to_content, process_metric_file_modification, FileModification, - FileModificationBatch, Modification, ModificationResult, ModifyFilesOutput, + process_metric_file_modification, ModificationResult, ModifyFilesOutput, ModifyFilesParams, }, file_types::file::FileWithId, @@ -160,7 +157,7 @@ impl ToolExecutor for ModifyMetricFilesTool { // Process results and generate output message let duration = start_time.elapsed().as_millis() as i64; - let mut output = ModifyFilesOutput { + let output = ModifyFilesOutput { message: String::new(), files: Vec::new(), duration, diff --git a/api/libs/handlers/src/chats/sharing/create_sharing_handler.rs b/api/libs/handlers/src/chats/sharing/create_sharing_handler.rs index b4edddc76..77d74ae90 100644 --- a/api/libs/handlers/src/chats/sharing/create_sharing_handler.rs +++ b/api/libs/handlers/src/chats/sharing/create_sharing_handler.rs @@ -84,7 +84,7 @@ pub async fn get_chat_exists(chat_id: &Uuid) -> Result { mod tests { use super::*; use database::enums::{AssetPermissionRole, AssetType, IdentityType}; - use sharing::create_share; + use uuid::Uuid; // Mock function to test permission checking diff --git a/api/libs/handlers/src/chats/sharing/list_sharing_handler.rs b/api/libs/handlers/src/chats/sharing/list_sharing_handler.rs index ec1a9ada2..19b0197d9 100644 --- a/api/libs/handlers/src/chats/sharing/list_sharing_handler.rs +++ b/api/libs/handlers/src/chats/sharing/list_sharing_handler.rs @@ -110,7 +110,7 @@ pub async fn list_chat_sharing_handler( #[cfg(test)] mod tests { - use super::*; + #[tokio::test] async fn test_list_chat_sharing_handler() { diff --git a/api/libs/handlers/src/collections/add_assets_to_collection_handler.rs b/api/libs/handlers/src/collections/add_assets_to_collection_handler.rs index 8a6273345..e7e7cc4b6 100644 --- a/api/libs/handlers/src/collections/add_assets_to_collection_handler.rs +++ b/api/libs/handlers/src/collections/add_assets_to_collection_handler.rs @@ -435,8 +435,8 @@ pub async fn add_assets_to_collection_handler( #[cfg(test)] mod tests { - use super::*; - use uuid::Uuid; + + #[tokio::test] async fn test_add_assets_to_collection_handler() { diff --git a/api/libs/handlers/src/collections/add_dashboards_to_collection_handler.rs b/api/libs/handlers/src/collections/add_dashboards_to_collection_handler.rs index b3839ca77..7d5a6142b 100644 --- a/api/libs/handlers/src/collections/add_dashboards_to_collection_handler.rs +++ b/api/libs/handlers/src/collections/add_dashboards_to_collection_handler.rs @@ -220,9 +220,9 @@ pub async fn add_dashboards_to_collection_handler( #[cfg(test)] mod tests { - use super::*; - use database::enums::{AssetPermissionRole, AssetType, IdentityType}; - use uuid::Uuid; + + + #[tokio::test] async fn test_add_dashboards_to_collection_handler() { diff --git a/api/libs/handlers/src/collections/remove_metrics_from_collection_handler.rs b/api/libs/handlers/src/collections/remove_metrics_from_collection_handler.rs index 97df60b5a..b4febf1c9 100644 --- a/api/libs/handlers/src/collections/remove_metrics_from_collection_handler.rs +++ b/api/libs/handlers/src/collections/remove_metrics_from_collection_handler.rs @@ -121,9 +121,9 @@ pub async fn remove_metrics_from_collection_handler( #[cfg(test)] mod tests { - use super::*; - use database::enums::{AssetPermissionRole, AssetType, IdentityType}; - use uuid::Uuid; + + + #[tokio::test] async fn test_remove_metrics_from_collection_handler() { diff --git a/api/libs/handlers/src/collections/update_collection_handler.rs b/api/libs/handlers/src/collections/update_collection_handler.rs index 683b51cf2..322d7d2f2 100644 --- a/api/libs/handlers/src/collections/update_collection_handler.rs +++ b/api/libs/handlers/src/collections/update_collection_handler.rs @@ -186,7 +186,7 @@ async fn update_collection_record( #[cfg(test)] mod tests { use super::*; - use database::models::Collection; + use std::sync::Once; use uuid::Uuid; diff --git a/api/libs/handlers/src/dashboards/create_dashboard_handler.rs b/api/libs/handlers/src/dashboards/create_dashboard_handler.rs index 560ebef26..8435d1ca5 100644 --- a/api/libs/handlers/src/dashboards/create_dashboard_handler.rs +++ b/api/libs/handlers/src/dashboards/create_dashboard_handler.rs @@ -132,8 +132,8 @@ pub async fn create_dashboard_handler(user_id: &Uuid) -> Result