Skip to content

Commit

Permalink
chore: rename (#4551)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Shiue <71320345+richardshiue@users.noreply.github.com>
  • Loading branch information
appflowy and richardshiue authored Jan 30, 2024
1 parent f6242f1 commit 0483e30
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 30 deletions.
8 changes: 4 additions & 4 deletions frontend/rust-lib/flowy-core/src/integrate/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
.initialize(
user_id,
user_workspace.id.clone(),
user_workspace.database_view_tracker_id,
user_workspace.workspace_database_object_id,
)
.await?;
document_manager
Expand Down Expand Up @@ -111,7 +111,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
.initialize(
user_id,
user_workspace.id.clone(),
user_workspace.database_view_tracker_id,
user_workspace.workspace_database_object_id,
)
.await?;
document_manager
Expand Down Expand Up @@ -197,7 +197,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
.initialize_with_new_user(
user_profile.uid,
user_workspace.id.clone(),
user_workspace.database_view_tracker_id,
user_workspace.workspace_database_object_id,
)
.await
.context("DatabaseManager error")?;
Expand Down Expand Up @@ -235,7 +235,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
.initialize(
user_id,
user_workspace.id.clone(),
user_workspace.database_view_tracker_id,
user_workspace.workspace_database_object_id,
)
.await?;
document_manager
Expand Down
16 changes: 8 additions & 8 deletions frontend/rust-lib/flowy-database2/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl DatabaseManager {
&self,
uid: i64,
workspace_id: String,
database_views_aggregate_id: String,
workspace_database_object_id: String,
) -> FlowyResult<()> {
// Clear all existing tasks
self.task_scheduler.write().await.clear_task();
Expand All @@ -98,12 +98,12 @@ impl DatabaseManager {
let mut collab_raw_data = CollabDocState::default();

// If the workspace database not exist in disk, try to fetch from remote.
if !self.is_collab_exist(uid, &collab_db, &database_views_aggregate_id) {
if !self.is_collab_exist(uid, &collab_db, &workspace_database_object_id) {
trace!("workspace database not exist, try to fetch from remote");
match self
.cloud_service
.get_collab_doc_state_db(
&database_views_aggregate_id,
&workspace_database_object_id,
CollabType::WorkspaceDatabase,
&workspace_id,
)
Expand All @@ -115,7 +115,7 @@ impl DatabaseManager {
Err(err) => {
return Err(FlowyError::record_not_found().with_context(format!(
"get workspace database :{} failed: {}",
database_views_aggregate_id, err,
workspace_database_object_id, err,
)));
},
}
Expand All @@ -125,11 +125,11 @@ impl DatabaseManager {
event!(
tracing::Level::INFO,
"open aggregate database views object: {}",
&database_views_aggregate_id
&workspace_database_object_id
);
let collab = collab_builder.build_collab_with_config(
uid,
&database_views_aggregate_id,
&workspace_database_object_id,
CollabType::WorkspaceDatabase,
collab_db.clone(),
collab_raw_data,
Expand All @@ -152,10 +152,10 @@ impl DatabaseManager {
&self,
user_id: i64,
workspace_id: String,
database_views_aggregate_id: String,
workspace_database_object_id: String,
) -> FlowyResult<()> {
self
.initialize(user_id, workspace_id, database_views_aggregate_id)
.initialize(user_id, workspace_id, workspace_database_object_id)
.await?;
Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ fn to_user_workspace(af_workspace: AFWorkspace) -> UserWorkspace {
id: af_workspace.workspace_id.to_string(),
name: af_workspace.workspace_name,
created_at: af_workspace.created_at,
database_view_tracker_id: af_workspace.database_storage_id.to_string(),
workspace_database_object_id: af_workspace.database_storage_id.to_string(),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ fn make_user_workspace() -> UserWorkspace {
id: uuid::Uuid::new_v4().to_string(),
name: "My Workspace".to_string(),
created_at: Default::default(),
database_view_tracker_id: uuid::Uuid::new_v4().to_string(),
workspace_database_object_id: uuid::Uuid::new_v4().to_string(),
}
}
10 changes: 8 additions & 2 deletions frontend/rust-lib/flowy-server/tests/supabase_test/user_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ async fn supabase_user_sign_up_test() {
let user: AuthResponse = user_service.sign_up(BoxAny::new(params)).await.unwrap();
assert!(!user.latest_workspace.id.is_empty());
assert!(!user.user_workspaces.is_empty());
assert!(!user.latest_workspace.database_view_tracker_id.is_empty());
assert!(!user
.latest_workspace
.workspace_database_object_id
.is_empty());
}

#[tokio::test]
Expand All @@ -38,7 +41,10 @@ async fn supabase_user_sign_up_with_existing_uuid_test() {
.unwrap();
let user: AuthResponse = user_service.sign_up(BoxAny::new(params)).await.unwrap();
assert!(!user.latest_workspace.id.is_empty());
assert!(!user.latest_workspace.database_view_tracker_id.is_empty());
assert!(!user
.latest_workspace
.workspace_database_object_id
.is_empty());
assert!(!user.user_workspaces.is_empty());
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/rust-lib/flowy-user-pub/src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub struct UserWorkspace {
pub created_at: DateTime<Utc>,
/// The database storage id is used indexing all the database views in current workspace.
#[serde(rename = "database_storage_id")]
pub database_view_tracker_id: String,
pub workspace_database_object_id: String,
}

impl UserWorkspace {
Expand All @@ -148,7 +148,7 @@ impl UserWorkspace {
id: workspace_id.to_string(),
name: "".to_string(),
created_at: Utc::now(),
database_view_tracker_id: Uuid::new_v4().to_string(),
workspace_database_object_id: Uuid::new_v4().to_string(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/rust-lib/flowy-user-pub/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'de> Visitor<'de> for SessionVisitor {
name: "My Workspace".to_string(),
created_at: Utc::now(),
// For historical reasons, the database_storage_id is constructed by the user_id.
database_view_tracker_id: STANDARD.encode(format!("{}:user:database", user_id)),
workspace_database_object_id: STANDARD.encode(format!("{}:user:database", user_id)),
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn migration_anon_user_on_sign_up(
// Migration of all objects except the folder and database_with_views
object_ids.retain(|id| {
id != &old_user.session.user_workspace.id
&& id != &old_user.session.user_workspace.database_view_tracker_id
&& id != &old_user.session.user_workspace.workspace_database_object_id
});

info!("migrate collab objects: {:?}", object_ids.len());
Expand Down Expand Up @@ -148,20 +148,20 @@ where
{
let database_with_views_collab = Collab::new(
old_user.session.user_id,
&old_user.session.user_workspace.database_view_tracker_id,
&old_user.session.user_workspace.workspace_database_object_id,
"phantom",
vec![],
);
database_with_views_collab.with_origin_transact_mut(|txn| {
old_collab_r_txn.load_doc_with_txn(
old_user.session.user_id,
&old_user.session.user_workspace.database_view_tracker_id,
&old_user.session.user_workspace.workspace_database_object_id,
txn,
)
})?;

let new_uid = new_user_session.user_id;
let new_object_id = &new_user_session.user_workspace.database_view_tracker_id;
let new_object_id = &new_user_session.user_workspace.workspace_database_object_id;

let array = DatabaseViewTrackerList::from_collab(&database_with_views_collab);
for database_view_tracker in array.get_all_database_tracker() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub async fn sync_supabase_user_data_to_cloud(
uid,
&workspace_id,
device_id,
&new_user_session.user_workspace.database_view_tracker_id,
&new_user_session.user_workspace.workspace_database_object_id,
collab_db,
user_service.clone(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub(crate) fn import_appflowy_data_folder(
// when doing import, we don't want to import the user workspace, database view tracker and the user awareness
all_imported_object_ids.retain(|id| id != &imported_session.user_workspace.id);
all_imported_object_ids
.retain(|id| id != &imported_session.user_workspace.database_view_tracker_id);
.retain(|id| id != &imported_session.user_workspace.workspace_database_object_id);
all_imported_object_ids
.retain(|id| id != &awareness_oid_from_user_uuid(&imported_session.user_uuid).to_string());

Expand Down Expand Up @@ -268,14 +268,14 @@ where
{
let database_view_tracker_collab = Collab::new(
other_session.user_id,
&other_session.user_workspace.database_view_tracker_id,
&other_session.user_workspace.workspace_database_object_id,
"phantom",
vec![],
);
database_view_tracker_collab.with_origin_transact_mut(|txn| {
other_collab_read_txn.load_doc_with_txn(
other_session.user_id,
&other_session.user_workspace.database_view_tracker_id,
&other_session.user_workspace.workspace_database_object_id,
txn,
)
})?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl TryFrom<(i64, &UserWorkspace)> for UserWorkspaceTable {
if value.1.id.is_empty() {
return Err(FlowyError::invalid_data().with_context("The id is empty"));
}
if value.1.database_view_tracker_id.is_empty() {
if value.1.workspace_database_object_id.is_empty() {
return Err(FlowyError::invalid_data().with_context("The database storage id is empty"));
}

Expand All @@ -32,7 +32,7 @@ impl TryFrom<(i64, &UserWorkspace)> for UserWorkspaceTable {
name: value.1.name.clone(),
uid: value.0,
created_at: value.1.created_at.timestamp(),
database_storage_id: value.1.database_view_tracker_id.clone(),
database_storage_id: value.1.workspace_database_object_id.clone(),
})
}
}
Expand All @@ -46,7 +46,7 @@ impl From<UserWorkspaceTable> for UserWorkspace {
.timestamp_opt(value.created_at, 0)
.single()
.unwrap_or_default(),
database_view_tracker_id: value.database_storage_id,
workspace_database_object_id: value.database_storage_id,
}
}
}

0 comments on commit 0483e30

Please sign in to comment.