mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[rust]: read workspace,app,view in create_time asc order
This commit is contained in:
parent
c21709b36f
commit
019f7cc45d
@ -25,7 +25,6 @@ CRATE_TYPE = "cdylib"
|
||||
BUILD_FLAG = "debug"
|
||||
FLUTTER_PLATFORM = "macos"
|
||||
FLUTTER_OUTPUT_DIR = "Debug"
|
||||
FEATURES = "flutter"
|
||||
PRODUCT_EXT = "app"
|
||||
|
||||
|
||||
|
@ -55,4 +55,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
|
||||
|
||||
COCOAPODS: 1.11.2
|
||||
COCOAPODS: 1.10.1
|
||||
|
@ -40,7 +40,6 @@ dependencies:
|
||||
flowy_log:
|
||||
path: packages/flowy_log
|
||||
flutter_quill:
|
||||
# path: packages/flutter-quill
|
||||
git:
|
||||
url: git@github.com:appflowy/flutter-quill.git
|
||||
ref: develop
|
||||
|
@ -27,7 +27,7 @@ pub(crate) async fn create_workspace_handler(
|
||||
pub(crate) async fn read_cur_workspace_handler(
|
||||
controller: Unit<Arc<WorkspaceController>>,
|
||||
) -> DataResult<Workspace, WorkspaceError> {
|
||||
let workspace = controller.read_cur_workspace().await?;
|
||||
let workspace = controller.read_current_workspace().await?;
|
||||
data_result(workspace)
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ pub(crate) async fn read_cur_workspace_handler(
|
||||
pub(crate) async fn read_workspace_apps_handler(
|
||||
controller: Unit<Arc<WorkspaceController>>,
|
||||
) -> DataResult<RepeatedApp, WorkspaceError> {
|
||||
let repeated_app = controller.read_workspace_apps().await?;
|
||||
let repeated_app = controller.read_current_workspace_apps().await?;
|
||||
data_result(repeated_app)
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ impl WorkspaceController {
|
||||
Ok(workspaces)
|
||||
}
|
||||
|
||||
pub(crate) async fn read_cur_workspace(&self) -> Result<Workspace, WorkspaceError> {
|
||||
pub(crate) async fn read_current_workspace(&self) -> Result<Workspace, WorkspaceError> {
|
||||
let workspace_id = get_current_workspace()?;
|
||||
let user_id = self.user.user_id()?;
|
||||
let params = QueryWorkspaceParams {
|
||||
@ -153,7 +153,7 @@ impl WorkspaceController {
|
||||
Ok(workspace)
|
||||
}
|
||||
|
||||
pub(crate) async fn read_workspace_apps(&self) -> Result<RepeatedApp, WorkspaceError> {
|
||||
pub(crate) async fn read_current_workspace_apps(&self) -> Result<RepeatedApp, WorkspaceError> {
|
||||
let workspace_id = get_current_workspace()?;
|
||||
let conn = self.database.db_connection()?;
|
||||
let repeated_app = self.read_local_apps(&workspace_id, &*conn)?;
|
||||
|
@ -41,6 +41,7 @@ impl AppTableSql {
|
||||
let app_table = dsl::app_table
|
||||
.filter(app_table::workspace_id.eq(workspace_id))
|
||||
.filter(app_table::is_trash.eq(is_trash))
|
||||
.order(app_table::create_time.asc())
|
||||
.load::<AppTable>(conn)?;
|
||||
|
||||
Ok(app_table)
|
||||
|
@ -41,6 +41,7 @@ impl ViewTableSql {
|
||||
pub(crate) fn read_views(belong_to_id: &str, conn: &SqliteConnection) -> Result<Vec<ViewTable>, WorkspaceError> {
|
||||
let view_tables = dsl::view_table
|
||||
.filter(view_table::belong_to_id.eq(belong_to_id))
|
||||
.order(view_table::create_time.asc())
|
||||
.into_boxed()
|
||||
.load::<ViewTable>(conn)?;
|
||||
|
||||
|
@ -32,16 +32,17 @@ impl WorkspaceTableSql {
|
||||
user_id: &str,
|
||||
conn: &SqliteConnection,
|
||||
) -> Result<Vec<WorkspaceTable>, WorkspaceError> {
|
||||
let workspaces = match workspace_id {
|
||||
None => dsl::workspace_table
|
||||
.filter(workspace_table::user_id.eq(user_id))
|
||||
.load::<WorkspaceTable>(conn)?,
|
||||
Some(workspace_id) => dsl::workspace_table
|
||||
.filter(workspace_table::user_id.eq(user_id))
|
||||
.filter(workspace_table::id.eq(&workspace_id))
|
||||
.load::<WorkspaceTable>(conn)?,
|
||||
let mut filter = dsl::workspace_table
|
||||
.filter(workspace_table::user_id.eq(user_id))
|
||||
.order(workspace_table::create_time.asc())
|
||||
.into_boxed();
|
||||
|
||||
if let Some(workspace_id) = workspace_id {
|
||||
filter = filter.filter(workspace_table::id.eq(workspace_id.to_owned()));
|
||||
};
|
||||
|
||||
let workspaces = filter.load::<WorkspaceTable>(conn)?;
|
||||
|
||||
Ok(workspaces)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user