Skip to content

Commit

Permalink
chore: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Oct 15, 2024
1 parent 64dfad2 commit c404ce5
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 36 deletions.
2 changes: 1 addition & 1 deletion frontend/rust-lib/dart-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::pin::Pin;
use std::sync::{Arc, RwLock};
use std::task::{Context, Poll};
use std::{ffi::CStr, os::raw::c_char};
use tokio::runtime::Builder;

use tokio::sync::mpsc;
use tokio::task::LocalSet;
use tracing::{debug, error, info, trace, warn};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl CalculationsController {

// In case there are calculations where empty cells are counted
// as a contribution to the value.
if cells.len() == 0 {
if cells.is_empty() {
let calculations = self.delegate.get_all_calculations(&self.view_id).await;
for calculation in calculations.into_iter() {
let cells = self
Expand Down Expand Up @@ -336,7 +336,7 @@ impl CalculationsController {
) -> Option<Calculation> {
let value = self
.calculations_service
.calculate(&field, calculation.calculation_type, cells);
.calculate(field, calculation.calculation_type, cells);

if value != calculation.value {
return Some(calculation.with_value(value));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use collab_database::fields::Field;
use collab_database::rows::{Cell, RowCell};
use collab_database::rows::{Cell};

use crate::entities::CalculationType;
use crate::services::field::TypeOptionCellExt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ impl DatabaseViewEditor {
) -> FlowyResult<()> {
let calculation_id = params
.calculation_id
.unwrap_or_else(|| gen_database_calculation_id());
.unwrap_or_else(gen_database_calculation_id);
let calculation = Calculation::none(
calculation_id,
params.field_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,15 +913,13 @@ where

if database_view_ids.contains(&new_view_id) {
true
} else {
if view.space_info().is_some() {
if !imported_collab_by_oid.contains_key(&view.id) {
not_exist_parent_view_ids.push(new_view_id);
}
true
} else {
imported_collab_by_oid.contains_key(&view.id)
} else if view.space_info().is_some() {
if !imported_collab_by_oid.contains_key(&view.id) {
not_exist_parent_view_ids.push(new_view_id);
}
true
} else {
imported_collab_by_oid.contains_key(&view.id)
}
});

Expand Down
43 changes: 20 additions & 23 deletions frontend/rust-lib/lib-infra/tests/task_test/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Error;
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use lib_infra::async_trait::async_trait;
use lib_infra::future::BoxResultFuture;

use lib_infra::priority_task::{
Task, TaskContent, TaskDispatcher, TaskHandler, TaskId, TaskResult, TaskRunner, TaskState,
};
Expand Down Expand Up @@ -132,23 +132,21 @@ impl RefCountValue for MockTextTaskHandler {
async fn did_remove(&self) {}
}

#[async_trait]
impl TaskHandler for MockTextTaskHandler {
fn handler_id(&self) -> &str {
"1"
}

fn run(&self, content: TaskContent) -> BoxResultFuture<(), Error> {
let mut rng = rand::thread_rng();
let millisecond = rng.gen_range(1..50);
Box::pin(async move {
match content {
TaskContent::Text(_s) => {
tokio::time::sleep(Duration::from_millis(millisecond)).await;
},
TaskContent::Blob(_) => panic!("Only support text"),
}
Ok(())
})
async fn run(&self, content: TaskContent) -> Result<(), Error> {
let millisecond = rand::thread_rng().gen_range(1..50);
match content {
TaskContent::Text(_s) => {
tokio::time::sleep(Duration::from_millis(millisecond)).await;
},
TaskContent::Blob(_) => panic!("Only support text"),
}
Ok(())
}
}

Expand Down Expand Up @@ -190,21 +188,20 @@ impl TaskHandler for MockBlobTaskHandler {

pub struct MockTimeoutTaskHandler();

#[async_trait]
impl TaskHandler for MockTimeoutTaskHandler {
fn handler_id(&self) -> &str {
"3"
}

fn run(&self, content: TaskContent) -> BoxResultFuture<(), Error> {
Box::pin(async move {
match content {
TaskContent::Text(_) => panic!("Only support blob"),
TaskContent::Blob(_bytes) => {
tokio::time::sleep(Duration::from_millis(2000)).await;
},
}
Ok(())
})
async fn run(&self, content: TaskContent) -> Result<(), Error> {
match content {
TaskContent::Text(_) => panic!("Only support blob"),
TaskContent::Blob(_bytes) => {
tokio::time::sleep(Duration::from_millis(2000)).await;
},
}
Ok(())
}
}

Expand Down

0 comments on commit c404ce5

Please sign in to comment.