From b1962c8e029d06ac14f57abdf64214646530aa18 Mon Sep 17 00:00:00 2001 From: tamo Date: Tue, 6 Apr 2021 15:43:27 +0200 Subject: [PATCH] remove legacy files from meilisearch that have been replaced by a macro in routes/settings/mod.rs --- .../settings/attributes_for_faceting.rs | 43 ------------------- .../routes/settings/displayed_attributes.rs | 25 ----------- .../routes/settings/searchable_attributes.rs | 34 --------------- .../src/routes/settings/stop_words.rs | 33 -------------- .../tests/settings/get_settings.rs | 2 +- 5 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 meilisearch-http/src/routes/settings/attributes_for_faceting.rs delete mode 100644 meilisearch-http/src/routes/settings/displayed_attributes.rs delete mode 100644 meilisearch-http/src/routes/settings/searchable_attributes.rs delete mode 100644 meilisearch-http/src/routes/settings/stop_words.rs diff --git a/meilisearch-http/src/routes/settings/attributes_for_faceting.rs b/meilisearch-http/src/routes/settings/attributes_for_faceting.rs deleted file mode 100644 index 6c881cff3..000000000 --- a/meilisearch-http/src/routes/settings/attributes_for_faceting.rs +++ /dev/null @@ -1,43 +0,0 @@ -use actix_web::{web, HttpResponse, get}; - -use crate::error::{Error, ResponseError}; -use crate::helpers::Authentication; -use crate::make_update_delete_routes; -use crate::Data; - -#[get( - "/indexes/{index_uid}/settings/attributes-for-faceting", - wrap = "Authentication::Private" -)] -async fn get( - data: web::Data, - index_uid: web::Path, -) -> Result { - let index = data - .db - .load() - .open_index(&index_uid.as_ref()) - .ok_or(Error::index_not_found(&index_uid.as_ref()))?; - - let attributes_for_faceting = data.db.load().main_read::<_, _, ResponseError>(|reader| { - let schema = index.main.schema(reader)?; - let attrs = index.main.attributes_for_faceting(reader)?; - let attr_names = match (&schema, &attrs) { - (Some(schema), Some(attrs)) => attrs - .iter() - .filter_map(|&id| schema.name(id)) - .map(str::to_string) - .collect(), - _ => vec![], - }; - Ok(attr_names) - })?; - - Ok(HttpResponse::Ok().json(attributes_for_faceting)) -} - -make_update_delete_routes!( - "/indexes/{index_uid}/settings/attributes-for-faceting", - Vec, - attributes_for_faceting -); diff --git a/meilisearch-http/src/routes/settings/displayed_attributes.rs b/meilisearch-http/src/routes/settings/displayed_attributes.rs deleted file mode 100644 index b9f36f718..000000000 --- a/meilisearch-http/src/routes/settings/displayed_attributes.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::collections::HashSet; - -use actix_web::{web, HttpResponse, get}; - -use crate::error::{Error, ResponseError}; -use crate::helpers::Authentication; -use crate::make_update_delete_routes; -use crate::Data; - -#[get( - "/indexes/{index_uid}/settings/displayed-attributes", - wrap = "Authentication::Private" -)] -async fn get( - data: web::Data, - index_uid: web::Path, -) -> Result { - todo!() -} - -make_update_delete_routes!( - "/indexes/{index_uid}/settings/displayed-attributes", - HashSet, - displayed_attributes -); diff --git a/meilisearch-http/src/routes/settings/searchable_attributes.rs b/meilisearch-http/src/routes/settings/searchable_attributes.rs deleted file mode 100644 index a337b0435..000000000 --- a/meilisearch-http/src/routes/settings/searchable_attributes.rs +++ /dev/null @@ -1,34 +0,0 @@ -use actix_web::{web, HttpResponse, get}; - -use crate::data::get_indexed_attributes; -use crate::error::{Error, ResponseError}; -use crate::helpers::Authentication; -use crate::make_update_delete_routes; -use crate::Data; - -#[get( - "/indexes/{index_uid}/settings/searchable-attributes", - wrap = "Authentication::Private" -)] -async fn get( - data: web::Data, - index_uid: web::Path, -) -> Result { - let index = data - .db - .load() - .open_index(&index_uid.as_ref()) - - .ok_or(Error::index_not_found(&index_uid.as_ref()))?; - let reader = data.db.load().main_read_txn()?; - let schema = index.main.schema(&reader)?; - let searchable_attributes: Option> = schema.as_ref().map(get_indexed_attributes); - - Ok(HttpResponse::Ok().json(searchable_attributes)) -} - -make_update_delete_routes!( - "/indexes/{index_uid}/settings/searchable-attributes", - Vec, - searchable_attributes -); diff --git a/meilisearch-http/src/routes/settings/stop_words.rs b/meilisearch-http/src/routes/settings/stop_words.rs deleted file mode 100644 index 05a753f46..000000000 --- a/meilisearch-http/src/routes/settings/stop_words.rs +++ /dev/null @@ -1,33 +0,0 @@ -use std::collections::BTreeSet; - -use crate::make_update_delete_routes; -use actix_web::{web, HttpResponse, get}; - -use crate::error::{Error, ResponseError}; -use crate::helpers::Authentication; -use crate::Data; - -#[get( - "/indexes/{index_uid}/settings/stop-words", - wrap = "Authentication::Private" -)] -async fn get( - data: web::Data, - index_uid: web::Path, -) -> Result { - let index = data - .db - .load() - .open_index(&index_uid.as_ref()) - .ok_or(Error::index_not_found(&index_uid.as_ref()))?; - let reader = data.db.load().main_read_txn()?; - let stop_words = index.main.stop_words(&reader)?; - - Ok(HttpResponse::Ok().json(stop_words)) -} - -make_update_delete_routes!( - "/indexes/{index_uid}/settings/stop-words", - BTreeSet, - stop_words -); diff --git a/meilisearch-http/tests/settings/get_settings.rs b/meilisearch-http/tests/settings/get_settings.rs index 82554ee22..34ab45be1 100644 --- a/meilisearch-http/tests/settings/get_settings.rs +++ b/meilisearch-http/tests/settings/get_settings.rs @@ -30,7 +30,7 @@ async fn get_settings() { "exactness" ]) ); - assert_eq!(settings["stopWords"], json!(null)); + assert_eq!(settings["stopWords"], json!([])); } #[actix_rt::test]