fix: import notion file base cases (#957)

This commit is contained in:
Nathan.fooo 2024-11-02 16:50:51 +08:00 committed by GitHub
parent 7c42cee11a
commit a5a5a6b59f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 18 deletions

14
Cargo.lock generated
View File

@ -2240,7 +2240,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=4175465382020f1bd9cd9aa0e0766178eac7b4e5#4175465382020f1bd9cd9aa0e0766178eac7b4e5"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=be6bb90faac22ca8443a950ea3deafc7ec99b3a8#be6bb90faac22ca8443a950ea3deafc7ec99b3a8"
dependencies = [
"anyhow",
"arc-swap",
@ -2265,7 +2265,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=4175465382020f1bd9cd9aa0e0766178eac7b4e5#4175465382020f1bd9cd9aa0e0766178eac7b4e5"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=be6bb90faac22ca8443a950ea3deafc7ec99b3a8#be6bb90faac22ca8443a950ea3deafc7ec99b3a8"
dependencies = [
"anyhow",
"async-trait",
@ -2304,7 +2304,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=4175465382020f1bd9cd9aa0e0766178eac7b4e5#4175465382020f1bd9cd9aa0e0766178eac7b4e5"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=be6bb90faac22ca8443a950ea3deafc7ec99b3a8#be6bb90faac22ca8443a950ea3deafc7ec99b3a8"
dependencies = [
"anyhow",
"arc-swap",
@ -2325,7 +2325,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=4175465382020f1bd9cd9aa0e0766178eac7b4e5#4175465382020f1bd9cd9aa0e0766178eac7b4e5"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=be6bb90faac22ca8443a950ea3deafc7ec99b3a8#be6bb90faac22ca8443a950ea3deafc7ec99b3a8"
dependencies = [
"anyhow",
"bytes",
@ -2345,7 +2345,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=4175465382020f1bd9cd9aa0e0766178eac7b4e5#4175465382020f1bd9cd9aa0e0766178eac7b4e5"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=be6bb90faac22ca8443a950ea3deafc7ec99b3a8#be6bb90faac22ca8443a950ea3deafc7ec99b3a8"
dependencies = [
"anyhow",
"arc-swap",
@ -2367,7 +2367,7 @@ dependencies = [
[[package]]
name = "collab-importer"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=4175465382020f1bd9cd9aa0e0766178eac7b4e5#4175465382020f1bd9cd9aa0e0766178eac7b4e5"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=be6bb90faac22ca8443a950ea3deafc7ec99b3a8#be6bb90faac22ca8443a950ea3deafc7ec99b3a8"
dependencies = [
"anyhow",
"async-recursion",
@ -2470,7 +2470,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=4175465382020f1bd9cd9aa0e0766178eac7b4e5#4175465382020f1bd9cd9aa0e0766178eac7b4e5"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=be6bb90faac22ca8443a950ea3deafc7ec99b3a8#be6bb90faac22ca8443a950ea3deafc7ec99b3a8"
dependencies = [
"anyhow",
"collab",

View File

@ -305,13 +305,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 = "4175465382020f1bd9cd9aa0e0766178eac7b4e5" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "4175465382020f1bd9cd9aa0e0766178eac7b4e5" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "4175465382020f1bd9cd9aa0e0766178eac7b4e5" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "4175465382020f1bd9cd9aa0e0766178eac7b4e5" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "4175465382020f1bd9cd9aa0e0766178eac7b4e5" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "4175465382020f1bd9cd9aa0e0766178eac7b4e5" }
collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "4175465382020f1bd9cd9aa0e0766178eac7b4e5" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "be6bb90faac22ca8443a950ea3deafc7ec99b3a8" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "be6bb90faac22ca8443a950ea3deafc7ec99b3a8" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "be6bb90faac22ca8443a950ea3deafc7ec99b3a8" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "be6bb90faac22ca8443a950ea3deafc7ec99b3a8" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "be6bb90faac22ca8443a950ea3deafc7ec99b3a8" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "be6bb90faac22ca8443a950ea3deafc7ec99b3a8" }
collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "be6bb90faac22ca8443a950ea3deafc7ec99b3a8" }
[features]
history = []

View File

@ -374,9 +374,9 @@ fn is_task_expired(timestamp: i64, last_process_at: Option<i64>) -> bool {
}
let elapsed = now - created_at;
let minutes = get_env_var("APPFLOWY_WORKER_IMPORT_TASK_EXPIRE_MINUTES", "10")
let minutes = get_env_var("APPFLOWY_WORKER_IMPORT_TASK_EXPIRE_MINUTES", "20")
.parse::<i64>()
.unwrap_or(10);
.unwrap_or(20);
elapsed.num_minutes() >= minutes
},
}
@ -1314,14 +1314,16 @@ pub struct NotionImportTask {
pub md5_base64: Option<String>,
#[serde(default)]
pub last_process_at: Option<i64>,
#[serde(default)]
pub file_size: Option<i64>,
}
impl Display for NotionImportTask {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"NotionImportTask {{ task_id: {}, workspace_id: {}, workspace_name: {}, user_name: {}, user_email: {} }}",
self.task_id, self.workspace_id, self.workspace_name, self.user_name, self.user_email
"NotionImportTask {{ task_id: {}, workspace_id: {}, file_size:{:?}, workspace_name: {}, user_name: {}, user_email: {} }}",
self.task_id, self.workspace_id, self.file_size, self.workspace_name, self.user_name, self.user_email
)
}
}

View File

@ -83,6 +83,7 @@ async fn create_import_handler(
"user_email": user_email,
"task_id": task_id.to_string(),
"workspace_id": workspace_id,
"file_size":params.content_length,
"created_at": timestamp,
"s3_key": s3_key,
"host": host,