server changes for the ID in the tree

This commit is contained in:
filipriec
2025-05-23 13:34:39 +02:00
parent ad37990da9
commit 5478a2ac27
4 changed files with 10 additions and 5 deletions

View File

@@ -35,8 +35,9 @@ message TableDefinitionResponse {
message ProfileTreeResponse { message ProfileTreeResponse {
message Table { message Table {
string name = 1; int64 id = 1;
repeated string depends_on = 2; string name = 2;
repeated string depends_on = 3;
} }
message Profile { message Profile {

Binary file not shown.

View File

@@ -42,9 +42,11 @@ pub struct ProfileTreeResponse {
pub mod profile_tree_response { pub mod profile_tree_response {
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Table { pub struct Table {
#[prost(string, tag = "1")] #[prost(int64, tag = "1")]
pub id: i64,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String, pub name: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "2")] #[prost(string, repeated, tag = "3")]
pub depends_on: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, pub depends_on: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
} }
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]

View File

@@ -26,6 +26,7 @@ pub async fn get_profile_tree(
let tables = sqlx::query!( let tables = sqlx::query!(
r#" r#"
SELECT SELECT
td.id as table_id,
td.table_name, td.table_name,
COALESCE( COALESCE(
json_agg( json_agg(
@@ -40,7 +41,7 @@ pub async fn get_profile_tree(
LEFT JOIN table_definition_links tdl ON td.id = tdl.source_table_id LEFT JOIN table_definition_links tdl ON td.id = tdl.source_table_id
LEFT JOIN table_definitions ltd ON tdl.linked_table_id = ltd.id LEFT JOIN table_definitions ltd ON tdl.linked_table_id = ltd.id
WHERE td.profile_id = $1 WHERE td.profile_id = $1
GROUP BY td.table_name GROUP BY td.id, td.table_name
"#, "#,
profile.id profile.id
) )
@@ -59,6 +60,7 @@ pub async fn get_profile_tree(
.unwrap_or_default(); .unwrap_or_default();
Table { Table {
id: record.table_id,
name: record.table_name, name: record.table_name,
depends_on: dependencies depends_on: dependencies
.into_iter() .into_iter()