From 820db6564ed1d3571b645ae0133891b1166f707a Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:41:45 +0800 Subject: [PATCH] chore: create space view for imported notion zip file (#863) --- Cargo.lock | 14 +++++------ Cargo.toml | 14 +++++------ .../src/import_worker/worker.rs | 3 ++- tests/workspace/import_test.rs | 23 +++++++++++-------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6fb5920b..a43f1a1b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2230,7 +2230,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698" dependencies = [ "anyhow", "arc-swap", @@ -2255,7 +2255,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698" dependencies = [ "anyhow", "async-trait", @@ -2294,7 +2294,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698" dependencies = [ "anyhow", "arc-swap", @@ -2315,7 +2315,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698" dependencies = [ "anyhow", "bytes", @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698" dependencies = [ "anyhow", "arc-swap", @@ -2357,7 +2357,7 @@ dependencies = [ [[package]] name = "collab-importer" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698" dependencies = [ "anyhow", "async-recursion", @@ -2454,7 +2454,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698" dependencies = [ "anyhow", "collab", diff --git a/Cargo.toml b/Cargo.toml index 937424036..b79922403 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -293,13 +293,13 @@ debug = true [patch.crates-io] # It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # So using patch to workaround this issue. -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" } -collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" } -collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" } -collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" } +collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" } +collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" } +collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" } [features] history = [] diff --git a/services/appflowy-worker/src/import_worker/worker.rs b/services/appflowy-worker/src/import_worker/worker.rs index 741ce51ca..1dfd8c0e1 100644 --- a/services/appflowy-worker/src/import_worker/worker.rs +++ b/services/appflowy-worker/src/import_worker/worker.rs @@ -316,6 +316,7 @@ async fn process_unzip_file( s3_client: &Arc, ) -> Result<(), ImportError> { let notion_importer = NotionImporter::new( + import_task.uid, unzip_dir_path, import_task.workspace_id.clone(), import_task.host.clone(), @@ -326,7 +327,7 @@ async fn process_unzip_file( .import() .await .map_err(ImportError::ImportCollabError)?; - let nested_views = imported.build_nested_views(import_task.uid).await; + let nested_views = imported.build_nested_views().await; trace!( "[Import]: {} imported nested views:{}", import_task.workspace_id, diff --git a/tests/workspace/import_test.rs b/tests/workspace/import_test.rs index 03681790a..61fcf6629 100644 --- a/tests/workspace/import_test.rs +++ b/tests/workspace/import_test.rs @@ -9,16 +9,18 @@ use std::time::Duration; async fn import_blog_post_test() { let (client, imported_workspace_id) = import_zip("blog_post.zip").await; let folder = client.get_folder(&imported_workspace_id).await; - let mut workspace_sub_views = folder.get_views_belong_to(&imported_workspace_id); + let mut space_views = folder.get_views_belong_to(&imported_workspace_id); assert_eq!( - workspace_sub_views.len(), + space_views.len(), 1, "Expected 1 view, found {:?}", - workspace_sub_views + space_views ); - let imported_view = workspace_sub_views.pop().unwrap(); - assert_eq!(imported_view.name, "Blog Post"); + let space_view = space_views.pop().unwrap(); + assert_eq!(space_view.name, "blog_post"); + let imported_view = folder.get_views_belong_to(&space_view.id).pop().unwrap(); + let document = client .get_document(&imported_workspace_id, &imported_view.id) .await; @@ -53,15 +55,18 @@ async fn import_project_and_task_zip_test() { let (client, imported_workspace_id) = import_zip("project&task.zip").await; let folder = client.get_folder(&imported_workspace_id).await; let workspace_database = client.get_workspace_database(&imported_workspace_id).await; - let mut workspace_sub_views = folder.get_views_belong_to(&imported_workspace_id); + let space_views = folder.get_views_belong_to(&imported_workspace_id); assert_eq!( - workspace_sub_views.len(), + space_views.len(), 1, "Expected 1 view, found {:?}", - workspace_sub_views + space_views ); + assert_eq!(space_views[0].name, "project&task"); + assert!(space_views[0].space_info().is_some()); - let imported_view = workspace_sub_views.pop().unwrap(); + let mut sub_views = folder.get_views_belong_to(&space_views[0].id); + let imported_view = sub_views.pop().unwrap(); assert_eq!(imported_view.name, "Projects & Tasks"); assert_eq!( imported_view.children.len(),