From c50a2b36aae8e0ac080bd39b2f4e59bdfd5549a8 Mon Sep 17 00:00:00 2001 From: Michael Chung Date: Sat, 23 Dec 2023 14:46:45 -0500 Subject: [PATCH] Add missing data in response get weight endpoint to have updated_at (the list weight has but the single weight doesnt) profile weight list endpoint weights_category is missing from the response, i need it for rendering the cards by what type of weight it is. --- .../mysql_queries/src/queries/model_weights/get_weight.rs | 8 ++++---- .../videofilter/rerender_a_video/download_model_file.rs | 4 ++-- .../src/http_server/endpoints/weights/get_weight.rs | 4 +++- .../http_server/endpoints/weights/list_weights_by_user.rs | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/lib/mysql_queries/src/queries/model_weights/get_weight.rs b/crates/lib/mysql_queries/src/queries/model_weights/get_weight.rs index 71efd4fc0d..6132adb8ed 100644 --- a/crates/lib/mysql_queries/src/queries/model_weights/get_weight.rs +++ b/crates/lib/mysql_queries/src/queries/model_weights/get_weight.rs @@ -14,7 +14,7 @@ use tokens::tokens::{model_weights::ModelWeightToken, users::UserToken}; // 'weights_type: enums::by_table::model_weights::weights_types::WeightsType' use this to map // Retrieved Model Weight can be constrained to the fields that are needed -pub struct RetrivedModelWeight { +pub struct RetrievedModelWeight { pub token: ModelWeightToken, pub title: String, pub weights_type: WeightsType, @@ -60,7 +60,7 @@ pub async fn get_weight_by_token( weight_token: &ModelWeightToken, can_see_deleted: bool, mysql_pool: &MySqlPool -) -> AnyhowResult> { +) -> AnyhowResult> { let mut connection = mysql_pool.acquire().await?; get_weights_by_token_with_connection(weight_token, can_see_deleted, &mut connection).await } @@ -69,7 +69,7 @@ pub async fn get_weights_by_token_with_connection( weight_token: &ModelWeightToken, can_see_deleted: bool, mysql_connection: &mut PoolConnection -) -> AnyhowResult> { +) -> AnyhowResult> { let maybe_result = if can_see_deleted { select_include_deleted(weight_token, mysql_connection).await } else { @@ -90,7 +90,7 @@ pub async fn get_weights_by_token_with_connection( // unwrap the result Ok( - Some(RetrivedModelWeight { + Some(RetrievedModelWeight { token: record.token, title: record.title, weights_type: record.weights_type, diff --git a/crates/service/job/inference_job/src/job/job_types/videofilter/rerender_a_video/download_model_file.rs b/crates/service/job/inference_job/src/job/job_types/videofilter/rerender_a_video/download_model_file.rs index 63e434beff..bc5ded36a7 100644 --- a/crates/service/job/inference_job/src/job/job_types/videofilter/rerender_a_video/download_model_file.rs +++ b/crates/service/job/inference_job/src/job/job_types/videofilter/rerender_a_video/download_model_file.rs @@ -7,7 +7,7 @@ use buckets::public::media_files::bucket_file_path::MediaFileBucketPath; use cloud_storage::bucket_client::BucketClient; use jobs_common::job_progress_reporter::job_progress_reporter::JobProgressReporter; use mysql_queries::queries::generic_inference::job::list_available_generic_inference_jobs::AvailableInferenceJob; -use mysql_queries::queries::model_weights::get_weight::RetrivedModelWeight; +use mysql_queries::queries::model_weights::get_weight::RetrievedModelWeight; use crate::job::job_loop::process_single_job_error::ProcessSingleJobError; use crate::util::maybe_download_file_from_bucket::{maybe_download_file_from_bucket, MaybeDownloadArgs}; @@ -18,7 +18,7 @@ pub struct ModelFile { } pub async fn download_model_file( - model_record: &Option, + model_record: &Option, public_bucket_client: &BucketClient, job_progress_reporter: &mut Box, job: &AvailableInferenceJob, diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/weights/get_weight.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/weights/get_weight.rs index 66980cbc0c..7a010d7f17 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/weights/get_weight.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/weights/get_weight.rs @@ -48,6 +48,7 @@ pub struct GetWeightResponse { version: i32, created_at: DateTime, + updated_at: DateTime, } #[derive(Deserialize,ToSchema)] @@ -181,7 +182,8 @@ pub async fn get_weight_handler( maybe_cached_user_ratings_ratio: weight.maybe_cached_user_ratings_ratio, cached_user_ratings_last_updated_at: weight.cached_user_ratings_last_updated_at, version: weight.version, - created_at: weight.created_at + created_at: weight.created_at, + updated_at: weight.updated_at }; let body = serde_json::to_string(&response) diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/weights/list_weights_by_user.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/weights/list_weights_by_user.rs index e93c50d50e..f3ece5b155 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/weights/list_weights_by_user.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/weights/list_weights_by_user.rs @@ -21,7 +21,7 @@ use crate::server_state::ServerState; pub struct Weight { weight_token: ModelWeightToken, title: String, - + weights_category: String, creator: UserDetailsLight, creator_set_visibility: Visibility, @@ -153,6 +153,7 @@ pub async fn list_weights_by_user_handler( Weight { weight_token: weight.token, title: weight.title, + weights_category: weight.weights_category.to_string(), creator: UserDetailsLight::from_db_fields( &weight.creator_user_token, &weight.creator_username,