feat: folder search mvp (#4665)

* feat: implement folder indexer

* feat: sqlite search views using fts5

* feat: add view indexing to user manager

* feat: implement folder indexer

* feat: add sqlite search documents

* feat: add document indexing to user manager

* feat: add document indexing to folder indexer

* chore: update collab rev

* feat: search frontend integration

* refactor: search index

* test: add event test

* chore: fix ci

* feat: initial command palette overlay impl (#4619)

* chore: test search engine

* chore: initial structure

* chore: replace old search request

* chore: enable log for lib-dispatch

* chore: move search manager to core

* feat: move traits and responsibility to search crate

* feat: move search to search crate

* feat: replace sqlite with tantivy

* feat: deserialize tantivy documents

* chore: fixes after rebase

* chore: clean code

* feat: fetch and sort results

* fix: code review + cleaning

* feat: support custom icons

* feat: support view layout icons

* feat: rename bloc and fix indexing

* fix: prettify dialog

* feat: score results

* chore: update collab rev

* feat: add recent view history to command palette

* test: add integration_tests

* fix: clippy changes

* fix: focus traversal in cmd palette

* fix: remove file after merging main

* chore: code review and panic-safe

* feat: index all views if index does not exist

* chore: improve logic with conditional

* chore: add is_empty check

* chore: abstract logic from folder manager init

* chore: update collab rev

* chore: code review

* chore: fixes after merge + update lock file

* chore: revert cargo lock

* fix: set icon type when removing icon

* fix: code review + dependency inversion

* fix: remove icon fix for not persisting icon type

* test: simple tests manipulating views

* test: create 100 views

* fix: tauri build

* chore: create 1000 views

* chore: create util methods

* chore: test

* chore: test

* chore: remove logs

* chore: fix build.rs

* chore: export models

* chore: enable clear cache on Rust-CI

* fix: navigate to newly created views

* fix: force disable setting workspace listener on rebuilds

* fix: remove late final

* fix: missing returns

* fix: localization and minor fixes

* test: add index assert to large test

* fix: missing section param after merging main

* chore: try fix unzip file error

* chore: lower the test

* feat: show hint when result is in trash

---------

Co-authored-by: nathan <nathan@appflowy.io>
Co-authored-by: Jiraffe7 <twajxjiraffe@gmail.com>
Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
Mathias Mogensen
2024-03-21 17:34:53 +01:00
committed by GitHub
parent 4e99952b0e
commit c1006c18c3
123 changed files with 4013 additions and 521 deletions

View File

@ -3,11 +3,11 @@ use event_integration::EventIntegrationTest;
use flowy_core::DEFAULT_NAME;
use flowy_user::entities::AuthenticatorPB;
use crate::util::unzip_history_user_db;
use crate::util::unzip;
#[tokio::test]
async fn reading_039_anon_user_data_test() {
let (cleaner, user_db_path) = unzip_history_user_db("./tests/asset", "039_local").unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", "039_local").unwrap();
let test =
EventIntegrationTest::new_with_user_data_path(user_db_path, DEFAULT_NAME.to_string()).await;
let first_level_views = test.get_all_workspace_views().await;
@ -42,7 +42,7 @@ async fn reading_039_anon_user_data_test() {
#[tokio::test]
async fn migrate_anon_user_data_to_af_cloud_test() {
let (cleaner, user_db_path) = unzip_history_user_db("./tests/asset", "040_local").unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", "040_local").unwrap();
// In the 040_local, the structure is:
// workspace:
// view: Document1

View File

@ -1,4 +1,4 @@
use crate::util::unzip_history_user_db;
use crate::util::unzip;
use assert_json_diff::assert_json_include;
use collab_database::rows::database_row_document_id_from_row_id;
use collab_entity::CollabType;
@ -13,8 +13,7 @@ use std::env::temp_dir;
async fn import_appflowy_data_need_migration_test() {
// In 037, the workspace array will be migrated to view.
let import_container_name = "037_local".to_string();
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", &import_container_name).unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", &import_container_name).unwrap();
// Getting started
// Document1
// Document2(fav)
@ -53,8 +52,7 @@ async fn import_appflowy_data_need_migration_test() {
#[tokio::test]
async fn import_appflowy_data_folder_into_new_view_test() {
let import_container_name = "040_local".to_string();
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", &import_container_name).unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", &import_container_name).unwrap();
// In the 040_local, the structure is:
// workspace:
// view: Document1
@ -122,8 +120,7 @@ async fn import_appflowy_data_folder_into_new_view_test() {
#[tokio::test]
async fn import_appflowy_data_folder_into_current_workspace_test() {
let import_container_name = "040_local".to_string();
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", &import_container_name).unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", &import_container_name).unwrap();
// In the 040_local, the structure is:
// workspace:
// view: Document1
@ -170,8 +167,7 @@ async fn import_appflowy_data_folder_into_current_workspace_test() {
#[tokio::test]
async fn import_appflowy_data_folder_into_new_view_test2() {
let import_container_name = "040_local_2".to_string();
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", &import_container_name).unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", &import_container_name).unwrap();
user_localhost_af_cloud().await;
let test = EventIntegrationTest::new_with_name(DEFAULT_NAME).await;
let _ = test.af_cloud_sign_up().await;
@ -210,8 +206,7 @@ async fn import_empty_appflowy_data_folder_test() {
#[tokio::test]
async fn import_appflowy_data_folder_multiple_times_test() {
let import_container_name = "040_local_2".to_string();
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", &import_container_name).unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", &import_container_name).unwrap();
// In the 040_local_2, the structure is:
// Getting Started
// Doc1

View File

@ -1,4 +1,4 @@
use crate::util::unzip_history_user_db;
use crate::util::unzip;
use event_integration::user_event::user_localhost_af_cloud;
use event_integration::EventIntegrationTest;
use flowy_core::DEFAULT_NAME;
@ -7,10 +7,9 @@ use std::time::Duration;
#[tokio::test]
async fn import_appflowy_data_folder_into_new_view_test() {
let import_container_name = "040_local".to_string();
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", &import_container_name).unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", &import_container_name).unwrap();
let (imported_af_folder_cleaner, imported_af_data_path) =
unzip_history_user_db("./tests/asset", &import_container_name).unwrap();
unzip("./tests/asset", &import_container_name).unwrap();
user_localhost_af_cloud().await;
let test =

View File

@ -8,7 +8,7 @@ use flowy_user::event_map::UserEvent::*;
#[tokio::test]
async fn user_update_with_reminder() {
let sdk = EventIntegrationTest::new().await;
let _ = sdk.sign_up_as_guest().await;
let _ = sdk.sign_up_as_anon().await;
let mut meta = HashMap::new();
meta.insert("object_id".to_string(), "".to_string());

View File

@ -1,11 +1,11 @@
use event_integration::EventIntegrationTest;
use flowy_core::DEFAULT_NAME;
use crate::util::unzip_history_user_db;
use crate::util::unzip;
#[tokio::test]
async fn collab_db_restore_test() {
let (cleaner, user_db_path) = unzip_history_user_db(
let (cleaner, user_db_path) = unzip(
"./tests/user/migration_test/history_user_db",
"038_collab_db_corrupt_restore",
)

View File

@ -2,11 +2,11 @@ use event_integration::EventIntegrationTest;
use flowy_core::DEFAULT_NAME;
use flowy_folder::entities::ViewLayoutPB;
use crate::util::unzip_history_user_db;
use crate::util::unzip;
#[tokio::test]
async fn migrate_historical_empty_document_test() {
let (cleaner, user_db_path) = unzip_history_user_db(
let (cleaner, user_db_path) = unzip(
"./tests/user/migration_test/history_user_db",
"historical_empty_document",
)

View File

@ -3,11 +3,11 @@ use flowy_core::DEFAULT_NAME;
use flowy_folder::entities::ViewLayoutPB;
use std::time::Duration;
use crate::util::unzip_history_user_db;
use crate::util::unzip;
#[tokio::test]
async fn migrate_020_historical_empty_document_test() {
let (cleaner, user_db_path) = unzip_history_user_db(
let (cleaner, user_db_path) = unzip(
"./tests/user/migration_test/history_user_db",
"020_historical_user_data",
)
@ -43,7 +43,7 @@ async fn migrate_020_historical_empty_document_test() {
#[tokio::test]
async fn migrate_036_fav_v1_workspace_array_test() {
// Used to test migration: FavoriteV1AndWorkspaceArrayMigration
let (cleaner, user_db_path) = unzip_history_user_db(
let (cleaner, user_db_path) = unzip(
"./tests/user/migration_test/history_user_db",
"036_fav_v1_workspace_array",
)
@ -65,7 +65,7 @@ async fn migrate_036_fav_v1_workspace_array_test() {
#[tokio::test]
async fn migrate_038_trash_test() {
// Used to test migration: WorkspaceTrashMapToSectionMigration
let (cleaner, user_db_path) = unzip_history_user_db("./tests/asset", "038_local").unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", "038_local").unwrap();
// Getting started
// Document1
// Document2(deleted)
@ -102,8 +102,7 @@ async fn migrate_038_trash_test() {
#[tokio::test]
async fn migrate_038_trash_test2() {
// Used to test migration: WorkspaceTrashMapToSectionMigration
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", "038_document_with_grid").unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", "038_document_with_grid").unwrap();
// Getting started
// document
// grid
@ -131,7 +130,7 @@ async fn migrate_038_trash_test2() {
#[tokio::test]
async fn collab_db_backup_test() {
// Used to test migration: WorkspaceTrashMapToSectionMigration
let (cleaner, user_db_path) = unzip_history_user_db("./tests/asset", "038_local").unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", "038_local").unwrap();
let test =
EventIntegrationTest::new_with_user_data_path(user_db_path, DEFAULT_NAME.to_string()).await;
@ -149,8 +148,7 @@ async fn collab_db_backup_test() {
#[tokio::test]
async fn delete_outdated_collab_db_backup_test() {
// Used to test migration: WorkspaceTrashMapToSectionMigration
let (cleaner, user_db_path) =
unzip_history_user_db("./tests/asset", "040_collab_backups").unwrap();
let (cleaner, user_db_path) = unzip("./tests/asset", "040_collab_backups").unwrap();
let test =
EventIntegrationTest::new_with_user_data_path(user_db_path, DEFAULT_NAME.to_string()).await;

View File

@ -120,7 +120,7 @@ async fn third_party_sign_up_with_duplicated_email() {
#[tokio::test]
async fn sign_up_as_guest_and_then_update_to_new_cloud_user_test() {
if get_supabase_config().is_some() {
let test = EventIntegrationTest::new_with_guest_user().await;
let test = EventIntegrationTest::new_anon().await;
let old_views = test
.folder_manager
.get_current_workspace_views()
@ -151,7 +151,7 @@ async fn sign_up_as_guest_and_then_update_to_new_cloud_user_test() {
#[tokio::test]
async fn sign_up_as_guest_and_then_update_to_existing_cloud_user_test() {
if get_supabase_config().is_some() {
let test = EventIntegrationTest::new_with_guest_user().await;
let test = EventIntegrationTest::new_anon().await;
let uuid = uuid::Uuid::new_v4().to_string();
let email = format!("{}@appflowy.io", nanoid!(6));
@ -172,7 +172,7 @@ async fn sign_up_as_guest_and_then_update_to_existing_cloud_user_test() {
// sign out and then sign in as a guest
test.sign_out().await;
let _sign_up_context = test.sign_up_as_guest().await;
let _sign_up_context = test.sign_up_as_anon().await;
let new_workspace = test.folder_manager.get_current_workspace().await.unwrap();
test
.create_view(&new_workspace.id, "new workspace child view".to_string())
@ -253,7 +253,7 @@ async fn update_user_profile_with_existing_email_test() {
async fn migrate_anon_document_on_cloud_signup() {
if get_supabase_config().is_some() {
let test = EventIntegrationTest::new().await;
let user_profile = test.sign_up_as_guest().await.user_profile;
let user_profile = test.sign_up_as_anon().await.user_profile;
let view = test
.create_view(&user_profile.workspace_id, "My first view".to_string())
@ -292,7 +292,7 @@ async fn migrate_anon_document_on_cloud_signup() {
#[tokio::test]
async fn migrate_anon_data_on_cloud_signup() {
if get_supabase_config().is_some() {
let (cleaner, user_db_path) = unzip_history_user_db(
let (cleaner, user_db_path) = unzip(
"./tests/user/supabase_test/history_user_db",
"workspace_sync",
)