chore: cargo clippy

This commit is contained in:
Zack Fu Zi Xiang 2024-09-05 14:27:03 +08:00
parent 22a416c99f
commit 42b98aeb77
No known key found for this signature in database
1 changed files with 16 additions and 28 deletions

View File

@ -701,21 +701,15 @@ impl PublishCollabDuplicator {
} }
} }
for m in type_option_values { for m in type_option_values {
if let Some(db_id) = m.get(&txn, "database_id") { if let Some(Out::Any(any::Any::String(s))) = m.get(&txn, "database_id") {
if let Out::Any(a) = db_id {
if let any::Any::String(s) = a {
if let Some(related_db_view) = published_db.database_relations.get(s.as_ref()) { if let Some(related_db_view) = published_db.database_relations.get(s.as_ref()) {
if let Some(dup_view_id) = if let Some(dup_view_id) = self.deep_copy_view(related_db_view, &new_view_id).await? {
self.deep_copy_view(related_db_view, &new_view_id).await?
{
m.insert(&mut txn, "database_id", dup_view_id); m.insert(&mut txn, "database_id", dup_view_id);
}; };
}; };
} }
} }
} }
}
}
// duplicate db collab rows // duplicate db collab rows
for (old_id, row_bin_data) in &published_db.database_row_collabs { for (old_id, row_bin_data) in &published_db.database_row_collabs {
@ -748,9 +742,7 @@ impl PublishCollabDuplicator {
let mut rel_row_idss = vec![]; let mut rel_row_idss = vec![];
for (_, out) in cells.iter(&txn) { for (_, out) in cells.iter(&txn) {
if let Ok(m) = out.cast::<MapRef>() { if let Ok(m) = out.cast::<MapRef>() {
if let Some(field_type) = m.get(&txn, "field_type") { if let Some(Out::Any(any::Any::BigInt(n))) = m.get(&txn, "field_type") {
if let Out::Any(a) = field_type {
if let any::Any::BigInt(n) = a {
if n == FieldType::Relation as i64 { if n == FieldType::Relation as i64 {
let relation_data = m.get(&txn, "data").ok_or_else(|| { let relation_data = m.get(&txn, "data").ok_or_else(|| {
AppError::RecordNotFound("no data found in relation cell".to_string()) AppError::RecordNotFound("no data found in relation cell".to_string())
@ -762,19 +754,15 @@ impl PublishCollabDuplicator {
} }
} }
} }
}
}
for rel_row_ids in rel_row_idss { for rel_row_ids in rel_row_idss {
let num_refs = rel_row_ids.len(&txn); let num_refs = rel_row_ids.len(&txn);
let mut pub_row_ids = Vec::with_capacity(num_refs as usize); let mut pub_row_ids = Vec::with_capacity(num_refs as usize);
for rel_row_id in rel_row_ids.iter(&txn) { for rel_row_id in rel_row_ids.iter(&txn) {
if let Out::Any(a) = rel_row_id { if let Out::Any(any::Any::String(s)) = rel_row_id {
if let any::Any::String(s) = a {
pub_row_ids.push(s); pub_row_ids.push(s);
} }
} }
}
rel_row_ids.remove_range(&mut txn, 0, num_refs); rel_row_ids.remove_range(&mut txn, 0, num_refs);
for pub_row_id in pub_row_ids { for pub_row_id in pub_row_ids {
let dup_row_id = self let dup_row_id = self