mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
setup clippy and make a pass on code
This commit is contained in:
parent
ea2a64a504
commit
2143226f04
@ -108,7 +108,7 @@ impl Data {
|
||||
let api_key = opt.api_key.clone();
|
||||
let server_pid = sysinfo::get_current_pid().unwrap();
|
||||
|
||||
let db = Arc::new(Database::open_or_create(opt.db_path.clone()).unwrap());
|
||||
let db = Arc::new(Database::open_or_create(opt.db_path).unwrap());
|
||||
|
||||
let inner_data = DataInner {
|
||||
db: db.clone(),
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(clippy::or_fun_call)]
|
||||
|
||||
pub mod data;
|
||||
pub mod error;
|
||||
pub mod helpers;
|
||||
|
@ -44,7 +44,7 @@ pub async fn delete_document(ctx: Request<Data>) -> SResult<Response> {
|
||||
|
||||
let index = ctx.index()?;
|
||||
let identifier = ctx.identifier()?;
|
||||
let document_id = meilisearch_core::serde::compute_document_id(identifier.clone());
|
||||
let document_id = meilisearch_core::serde::compute_document_id(identifier);
|
||||
let db = &ctx.state().db;
|
||||
let mut update_writer = db.update_write_txn()?;
|
||||
let mut documents_deletion = index.documents_deletion();
|
||||
@ -69,7 +69,7 @@ pub async fn get_all_documents(ctx: Request<Data>) -> SResult<Response> {
|
||||
ctx.is_allowed(DocumentsRead)?;
|
||||
|
||||
let index = ctx.index()?;
|
||||
let query: BrowseQuery = ctx.query().unwrap_or(BrowseQuery::default());
|
||||
let query: BrowseQuery = ctx.query().unwrap_or_default();
|
||||
|
||||
let offset = query.offset.unwrap_or(0);
|
||||
let limit = query.limit.unwrap_or(20);
|
||||
@ -115,7 +115,7 @@ fn find_identifier(document: &IndexMap<String, Value>) -> Option<String> {
|
||||
return Some(key.to_string());
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
|
@ -159,7 +159,7 @@ pub async fn create_index(mut ctx: Request<Data>) -> SResult<Response> {
|
||||
writer.commit()?;
|
||||
|
||||
let response_body = IndexCreateResponse {
|
||||
name: name,
|
||||
name,
|
||||
uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
|
@ -64,7 +64,7 @@ pub async fn search_with_url_query(ctx: Request<Data>) -> SResult<Response> {
|
||||
let attributes_to_crop = schema
|
||||
.displayed_name()
|
||||
.iter()
|
||||
.map(|attr| (attr.to_string(), crop_length))
|
||||
.map(|attr| ((*attr).to_string(), crop_length))
|
||||
.collect();
|
||||
search_builder.attributes_to_crop(attributes_to_crop);
|
||||
} else {
|
||||
@ -81,7 +81,7 @@ pub async fn search_with_url_query(ctx: Request<Data>) -> SResult<Response> {
|
||||
schema
|
||||
.displayed_name()
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.map(|s| (*s).to_string())
|
||||
.collect()
|
||||
} else {
|
||||
attributes_to_highlight
|
||||
|
@ -1,5 +1,5 @@
|
||||
use meilisearch_core::settings::{Settings, SettingsUpdate, UpdateState};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::Deserialize;
|
||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||
use tide::{Request, Response};
|
||||
|
||||
@ -57,10 +57,10 @@ pub async fn get_all(ctx: Request<Data>) -> SResult<Response> {
|
||||
let identifier = schema.clone().map(|s| s.identifier().to_owned());
|
||||
let searchable_attributes = schema
|
||||
.clone()
|
||||
.map(|s| s.indexed_name().iter().map(|s| s.to_string()).collect());
|
||||
.map(|s| s.indexed_name().iter().map(|s| (*s).to_string()).collect());
|
||||
let displayed_attributes = schema
|
||||
.clone()
|
||||
.map(|s| s.displayed_name().iter().map(|s| s.to_string()).collect());
|
||||
.map(|s| s.displayed_name().iter().map(|s| (*s).to_string()).collect());
|
||||
let index_new_fields = schema.map(|s| s.index_new_fields());
|
||||
|
||||
let settings = Settings {
|
||||
@ -268,7 +268,7 @@ pub async fn get_searchable(ctx: Request<Data>) -> SResult<Response> {
|
||||
let schema = index.main.schema(&reader)?;
|
||||
|
||||
let searchable_attributes: Option<HashSet<String>> =
|
||||
schema.map(|s| s.indexed_name().iter().map(|i| i.to_string()).collect());
|
||||
schema.map(|s| s.indexed_name().iter().map(|i| (*i).to_string()).collect());
|
||||
|
||||
Ok(tide::Response::new(200)
|
||||
.body_json(&searchable_attributes)
|
||||
@ -322,7 +322,7 @@ pub async fn displayed(ctx: Request<Data>) -> SResult<Response> {
|
||||
let schema = index.main.schema(&reader)?;
|
||||
|
||||
let displayed_attributes: Option<HashSet<String>> =
|
||||
schema.map(|s| s.displayed_name().iter().map(|i| i.to_string()).collect());
|
||||
schema.map(|s| s.displayed_name().iter().map(|i| (*i).to_string()).collect());
|
||||
|
||||
Ok(tide::Response::new(200)
|
||||
.body_json(&displayed_attributes)
|
||||
|
Loading…
Reference in New Issue
Block a user