chore: re-implement get_filter_by_field_id function (#4678)

* chore: remove inaccurate database view function

* chore: update collab rev

* chore: fix clippy

---------

Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
Richard Shiue 2024-02-22 08:07:59 +08:00 committed by GitHub
parent 6636731487
commit f1831d07af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 49 additions and 46 deletions

View File

@ -817,7 +817,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"async-trait",
@ -839,7 +839,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"async-trait",
@ -868,7 +868,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"collab",
@ -887,7 +887,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"bytes",
@ -902,7 +902,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"chrono",
@ -939,7 +939,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"async-stream",
@ -978,7 +978,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"collab",

View File

@ -92,10 +92,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "29a
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }

View File

@ -65,10 +65,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "29a
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }

View File

@ -745,7 +745,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"async-trait",
@ -767,7 +767,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"async-trait",
@ -796,7 +796,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"collab",
@ -815,7 +815,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"bytes",
@ -830,7 +830,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"chrono",
@ -867,7 +867,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"async-stream",
@ -906,7 +906,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=195fabd025c3021ce0a42a3f76b8f2bad44cb45c#195fabd025c3021ce0a42a3f76b8f2bad44cb45c"
dependencies = [
"anyhow",
"collab",

View File

@ -115,10 +115,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "29a
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "195fabd025c3021ce0a42a3f76b8f2bad44cb45c" }

View File

@ -6,7 +6,7 @@ use std::sync::Arc;
pub trait CollabCloudPluginProvider: Send + Sync + 'static {
fn provider_type(&self) -> CollabPluginProviderType;
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>>;
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Box<dyn CollabPlugin>>>;
fn is_sync_enabled(&self) -> bool;
}
@ -19,7 +19,7 @@ where
(**self).provider_type()
}
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Box<dyn CollabPlugin>>> {
(**self).get_plugins(context)
}

View File

@ -326,7 +326,7 @@ impl CollabCloudPluginProvider for ServerProvider {
}
#[instrument(level = "debug", skip(self, context), fields(server_type = %self.get_server_type()))]
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Box<dyn CollabPlugin>>> {
// If the user is local, we don't need to create a sync plugin.
if self.get_server_type().is_local() {
debug!(
@ -345,7 +345,7 @@ impl CollabCloudPluginProvider for ServerProvider {
} => {
if let Ok(server) = self.get_server() {
to_fut(async move {
let mut plugins: Vec<Arc<dyn CollabPlugin>> = vec![];
let mut plugins: Vec<Box<dyn CollabPlugin>> = vec![];
// If the user is local, we don't need to create a sync plugin.
@ -372,7 +372,7 @@ impl CollabCloudPluginProvider for ServerProvider {
!is_connected,
ws_connect_state,
);
plugins.push(Arc::new(sync_plugin));
plugins.push(Box::new(sync_plugin));
},
Ok(None) => {
tracing::error!("🔴Failed to get collab ws channel: channel is none");
@ -392,13 +392,13 @@ impl CollabCloudPluginProvider for ServerProvider {
local_collab,
local_collab_db,
} => {
let mut plugins: Vec<Arc<dyn CollabPlugin>> = vec![];
let mut plugins: Vec<Box<dyn CollabPlugin>> = vec![];
if let Some(remote_collab_storage) = self
.get_server()
.ok()
.and_then(|provider| provider.collab_storage(&collab_object))
{
plugins.push(Arc::new(SupabaseDBPlugin::new(
plugins.push(Box::new(SupabaseDBPlugin::new(
uid,
collab_object,
local_collab,

View File

@ -1528,7 +1528,9 @@ impl DatabaseViewOperation for DatabaseViewOperationImpl {
self
.database
.lock()
.get_filter_by_field_id::<Filter>(view_id, field_id)
.get_all_filters::<Filter>(view_id)
.into_iter()
.find(|filter| filter.field_id == field_id)
}
fn get_layout_setting(&self, view_id: &str, layout_ty: &DatabaseLayout) -> Option<LayoutSetting> {

View File

@ -197,7 +197,7 @@ impl CollabCloudPluginProvider for DefaultCollabStorageProvider {
CollabPluginProviderType::Local
}
fn get_plugins(&self, _context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
fn get_plugins(&self, _context: CollabPluginProviderContext) -> Fut<Vec<Box<dyn CollabPlugin>>> {
to_fut(async move { vec![] })
}

View File

@ -234,7 +234,7 @@ impl FolderManager {
match result {
Ok(folder_updates) => {
info!(
"Get folder updates via {}, number of updates: {}",
"Get folder updates via {}, doc state len: {}",
self.cloud_service.service_name(),
folder_updates.len()
);

View File

@ -6,7 +6,7 @@ use collab_entity::reminder::Reminder;
use collab_entity::CollabType;
use collab_integrate::collab_builder::CollabBuilderConfig;
use collab_user::core::{MutexUserAwareness, UserAwareness};
use tracing::{error, trace};
use tracing::{error, instrument, trace};
use collab_integrate::CollabKVDB;
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
@ -123,6 +123,7 @@ impl UserManager {
/// # Returns
/// - Returns `Ok(())` if the user's awareness is successfully initialized.
/// - May return errors of type `FlowyError` if any issues arise during the initialization.
#[instrument(level = "info", skip(self, session, source), err)]
async fn try_initial_user_awareness(
&self,
session: &Session,