chore: clippy

This commit is contained in:
nathan 2024-10-15 17:12:07 +08:00
parent 64dfad284e
commit c404ce5297
6 changed files with 31 additions and 36 deletions

View file

@ -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};

View file

@ -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
@ -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));

View file

@ -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;

View file

@ -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,

View file

@ -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)
}
});

View file

@ -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,
};
@ -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(())
}
}
@ -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(())
}
}