Skip to content

Commit

Permalink
fix cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
heqingpan committed Oct 21, 2024
1 parent ee94b25 commit 9575a57
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 33 deletions.
12 changes: 6 additions & 6 deletions src/transfer/sqlite/dao/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ impl<'a> ConfigDao<'a> {
}
}

pub fn execute(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<usize> {
sqlite_execute(&self.conn, sql, args)
pub fn execute(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<usize> {
sqlite_execute(self.conn, sql, args)
}

pub fn fetch(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<Vec<ConfigDO>> {
sqlite_fetch(&self.conn, sql, args, ConfigDO::from_row)
pub fn fetch(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<Vec<ConfigDO>> {
sqlite_fetch(self.conn, sql, args, ConfigDO::from_row)
}

pub fn fetch_count(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<u64> {
sqlite_fetch_count(&self.conn, sql, args)
pub fn fetch_count(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<u64> {
sqlite_fetch_count(self.conn, sql, args)
}

pub fn insert(&self, record: &ConfigDO) -> anyhow::Result<usize> {
Expand Down
12 changes: 6 additions & 6 deletions src/transfer/sqlite/dao/config_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,20 @@ impl<'a> ConfigHistoryDao<'a> {
}
}

pub fn execute(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<usize> {
sqlite_execute(&self.conn, sql, args)
pub fn execute(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<usize> {
sqlite_execute(self.conn, sql, args)
}

pub fn fetch(
&self,
sql: &str,
args: &Vec<serde_json::Value>,
args: &[serde_json::Value],
) -> anyhow::Result<Vec<ConfigHistoryDO>> {
sqlite_fetch(&self.conn, sql, args, ConfigHistoryDO::from_row)
sqlite_fetch(self.conn, sql, args, ConfigHistoryDO::from_row)
}

pub fn fetch_count(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<u64> {
sqlite_fetch_count(&self.conn, sql, args)
pub fn fetch_count(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<u64> {
sqlite_fetch_count(self.conn, sql, args)
}

pub fn insert(&self, record: &ConfigHistoryDO) -> anyhow::Result<usize> {
Expand Down
1 change: 1 addition & 0 deletions src/transfer/sqlite/dao/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::field_reassign_with_default)]
pub mod config;
pub mod config_history;
pub mod tenant;
Expand Down
12 changes: 6 additions & 6 deletions src/transfer/sqlite/dao/tenant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ impl<'a> TenantDao<'a> {
}
}

pub fn execute(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<usize> {
sqlite_execute(&self.conn, sql, args)
pub fn execute(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<usize> {
sqlite_execute(self.conn, sql, args)
}

pub fn fetch(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<Vec<TenantDO>> {
sqlite_fetch(&self.conn, sql, args, TenantDO::from_row)
pub fn fetch(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<Vec<TenantDO>> {
sqlite_fetch(self.conn, sql, args, TenantDO::from_row)
}

pub fn fetch_count(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<u64> {
sqlite_fetch_count(&self.conn, sql, args)
pub fn fetch_count(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<u64> {
sqlite_fetch_count(self.conn, sql, args)
}

pub fn insert(&self, record: &TenantDO) -> anyhow::Result<usize> {
Expand Down
12 changes: 6 additions & 6 deletions src/transfer/sqlite/dao/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ impl<'a> UserDao<'a> {
}
}

pub fn execute(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<usize> {
sqlite_execute(&self.conn, sql, args)
pub fn execute(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<usize> {
sqlite_execute(self.conn, sql, args)
}

pub fn fetch(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<Vec<UserDO>> {
sqlite_fetch(&self.conn, sql, args, UserDO::from_row)
pub fn fetch(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<Vec<UserDO>> {
sqlite_fetch(self.conn, sql, args, UserDO::from_row)
}

pub fn fetch_count(&self, sql: &str, args: &Vec<serde_json::Value>) -> anyhow::Result<u64> {
sqlite_fetch_count(&self.conn, sql, args)
pub fn fetch_count(&self, sql: &str, args: &[serde_json::Value]) -> anyhow::Result<u64> {
sqlite_fetch_count(self.conn, sql, args)
}

pub fn insert(&self, record: &UserDO) -> anyhow::Result<usize> {
Expand Down
14 changes: 5 additions & 9 deletions src/transfer/sqlite_to_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ fn apply_config(
table_seq: &mut TableSeq,
writer_actor: &Addr<TransferWriterActor>,
) -> anyhow::Result<()> {
let config_dao = ConfigDao::new(&conn);
let config_history_dao = ConfigHistoryDao::new(&conn);
let config_dao = ConfigDao::new(conn);
let config_history_dao = ConfigHistoryDao::new(conn);
let config_param = ConfigParam::default();
let mut count = 0;
//query all config
Expand Down Expand Up @@ -120,11 +120,7 @@ fn build_config_record(
}
}
let need_pull_current = if let Some(last_content) = &last_content {
if last_content == &current_current {
false
} else {
true
}
last_content != &current_current
} else {
true
};
Expand All @@ -150,7 +146,7 @@ fn build_config_record(

fn apply_tenant(conn: &Connection, writer_actor: &Addr<TransferWriterActor>) -> anyhow::Result<()> {
let mut count = 0;
let tenant_dao = TenantDao::new(&conn);
let tenant_dao = TenantDao::new(conn);
let param = TenantParam::default();
for item in tenant_dao.query(&param)? {
let key = if let Some(v) = &item.tenant_id {
Expand Down Expand Up @@ -178,7 +174,7 @@ fn apply_tenant(conn: &Connection, writer_actor: &Addr<TransferWriterActor>) ->

fn apply_user(conn: &Connection, writer_actor: &Addr<TransferWriterActor>) -> anyhow::Result<()> {
let mut count = 0;
let user_dao = UserDao::new(&conn);
let user_dao = UserDao::new(conn);
let param = UserParam::default();
for item in user_dao.query(&param)? {
let key = if let Some(v) = &item.username {
Expand Down

0 comments on commit 9575a57

Please sign in to comment.