diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index b3f6d94e..3755d503 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -55,9 +55,6 @@ service TableDefinition { // Copies one complete profile into a new profile without copying table data. rpc CopyProfile(CopyProfileRequest) returns (CopyProfileResponse); - // Returns the stored rename history for column aliases in one profile. - rpc GetColumnAliasRenameHistory(GetColumnAliasRenameHistoryRequest) returns (GetColumnAliasRenameHistoryResponse); - // Returns the unified append-only history for column and option aliases. rpc GetAliasChangeHistory(GetAliasChangeHistoryRequest) returns (GetAliasChangeHistoryResponse); @@ -463,31 +460,6 @@ message CopyProfileResponse { int32 scripts_copied = 4; } -// Request to fetch recorded column alias rename history for one profile. -message GetColumnAliasRenameHistoryRequest { - string profile_name = 1; - - // Filter. When omitted, returns all tables in the profile. - optional int64 table_definition_id = 2; -} - -// One recorded column alias rename. -message ColumnAliasRenameHistoryEntry { - int64 id = 1; - string profile_name = 2; - int64 table_definition_id = 3; - string table_name = 4; - string old_column_name = 5; - string new_column_name = 6; - string created_at = 7; -} - -// Response with stored column alias rename history rows. -message GetColumnAliasRenameHistoryResponse { - string profile_name = 1; - repeated ColumnAliasRenameHistoryEntry entries = 2; -} - enum AliasChangeKind { ALIAS_CHANGE_KIND_UNSPECIFIED = 0; ALIAS_CHANGE_KIND_COLUMN = 1; diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index f6f8374b..ff1141c9 100644 Binary files a/common/src/proto/descriptor.bin and b/common/src/proto/descriptor.bin differ diff --git a/common/src/proto/komp_ac.table_definition.rs b/common/src/proto/komp_ac.table_definition.rs index b8b02056..587bda7d 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -447,44 +447,6 @@ pub struct CopyProfileResponse { #[prost(int32, tag = "4")] pub scripts_copied: i32, } -/// Request to fetch recorded column alias rename history for one profile. -#[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct GetColumnAliasRenameHistoryRequest { - #[prost(string, tag = "1")] - pub profile_name: ::prost::alloc::string::String, - /// Filter. When omitted, returns all tables in the profile. - #[prost(int64, optional, tag = "2")] - pub table_definition_id: ::core::option::Option, -} -/// One recorded column alias rename. -#[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct ColumnAliasRenameHistoryEntry { - #[prost(int64, tag = "1")] - pub id: i64, - #[prost(string, tag = "2")] - pub profile_name: ::prost::alloc::string::String, - #[prost(int64, tag = "3")] - pub table_definition_id: i64, - #[prost(string, tag = "4")] - pub table_name: ::prost::alloc::string::String, - #[prost(string, tag = "5")] - pub old_column_name: ::prost::alloc::string::String, - #[prost(string, tag = "6")] - pub new_column_name: ::prost::alloc::string::String, - #[prost(string, tag = "7")] - pub created_at: ::prost::alloc::string::String, -} -/// Response with stored column alias rename history rows. -#[derive(serde::Serialize, serde::Deserialize)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetColumnAliasRenameHistoryResponse { - #[prost(string, tag = "1")] - pub profile_name: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub entries: ::prost::alloc::vec::Vec, -} #[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct GetAliasChangeHistoryRequest { @@ -1459,36 +1421,6 @@ pub mod table_definition_client { ); self.inner.unary(req, path, codec).await } - /// Returns the stored rename history for column aliases in one profile. - pub async fn get_column_alias_rename_history( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic_prost::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/komp_ac.table_definition.TableDefinition/GetColumnAliasRenameHistory", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "komp_ac.table_definition.TableDefinition", - "GetColumnAliasRenameHistory", - ), - ); - self.inner.unary(req, path, codec).await - } /// Returns the unified append-only history for column and option aliases. pub async fn get_alias_change_history( &mut self, @@ -1759,14 +1691,6 @@ pub mod table_definition_server { tonic::Response, tonic::Status, >; - /// Returns the stored rename history for column aliases in one profile. - async fn get_column_alias_rename_history( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; /// Returns the unified append-only history for column and option aliases. async fn get_alias_change_history( &self, @@ -2423,60 +2347,6 @@ pub mod table_definition_server { }; Box::pin(fut) } - "/komp_ac.table_definition.TableDefinition/GetColumnAliasRenameHistory" => { - #[allow(non_camel_case_types)] - struct GetColumnAliasRenameHistorySvc( - pub Arc, - ); - impl< - T: TableDefinition, - > tonic::server::UnaryService< - super::GetColumnAliasRenameHistoryRequest, - > for GetColumnAliasRenameHistorySvc { - type Response = super::GetColumnAliasRenameHistoryResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::GetColumnAliasRenameHistoryRequest, - >, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_column_alias_rename_history( - &inner, - request, - ) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetColumnAliasRenameHistorySvc(inner); - let codec = tonic_prost::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } "/komp_ac.table_definition.TableDefinition/GetAliasChangeHistory" => { #[allow(non_camel_case_types)] struct GetAliasChangeHistorySvc(pub Arc); diff --git a/komp-app/src/grpc.rs b/komp-app/src/grpc.rs index 544a1c2f..6e96be03 100644 --- a/komp-app/src/grpc.rs +++ b/komp-app/src/grpc.rs @@ -1190,16 +1190,16 @@ impl GrpcClient { .into_inner()) } - pub async fn get_column_alias_rename_history( + pub async fn get_alias_change_history( &mut self, - request: common::proto::komp_ac::table_definition::GetColumnAliasRenameHistoryRequest, - ) -> Result { + request: common::proto::komp_ac::table_definition::GetAliasChangeHistoryRequest, + ) -> Result { let request = self.authenticated_request(request)?; Ok(self .table_definition_client - .get_column_alias_rename_history(request) + .get_alias_change_history(request) .await - .context("gRPC GetColumnAliasRenameHistory call failed")? + .context("gRPC GetAliasChangeHistory call failed")? .into_inner()) } diff --git a/server b/server index 1804c1dd..d7f3b280 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 1804c1dd19206ff3ac21f7a849807fb117dd0ad7 +Subproject commit d7f3b280849d74df1bd7400a0d78178d53764cf6 diff --git a/web/src/pages/admin/table_definition/loader.rs b/web/src/pages/admin/table_definition/loader.rs index 33ebacc4..6e1ed01e 100644 --- a/web/src/pages/admin/table_definition/loader.rs +++ b/web/src/pages/admin/table_definition/loader.rs @@ -20,8 +20,8 @@ use crate::{ definitions::{ common::Empty, table_definition::{ - GetColumnAliasRenameHistoryRequest, GetProfileDetailsRequest, GetTableCatalogRequest, - MoneyRounding, table_definition_client::TableDefinitionClient, + AliasChangeKind, GetAliasChangeHistoryRequest, GetProfileDetailsRequest, + GetTableCatalogRequest, MoneyRounding, table_definition_client::TableDefinitionClient, }, }, pages::table_scope, @@ -249,12 +249,16 @@ pub(crate) async fn load_page( // The history is per profile; a selected table narrows it to that table. let history = match inputs.selection.has_profile() { true => { - let request = GetColumnAliasRenameHistoryRequest { + let request = GetAliasChangeHistoryRequest { profile_name: inputs.selection.profile.clone(), table_definition_id: detail.as_ref().map(|detail| detail.id), + column_id: None, + alias_kind: AliasChangeKind::Column as i32, + option_value: None, + limit: 0, }; definitions - .get_column_alias_rename_history( + .get_alias_change_history( authenticated_request(headers, request) .map_err(|_| LoadError::Unauthenticated)?, ) @@ -265,9 +269,9 @@ pub(crate) async fn load_page( .into_iter() .map(|entry| RenameEntry { table_name: entry.table_name, - old_column_name: entry.old_column_name, - new_column_name: entry.new_column_name, - created_at: entry.created_at, + old_column_name: entry.old_alias.unwrap_or_default(), + new_column_name: entry.new_alias.unwrap_or_default(), + created_at: entry.changed_at, }) .collect() }