diff --git a/src/database.rs b/src/database.rs
index 0b8b798..bbf4c5f 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -36,7 +36,7 @@ pub fn add_all_titles<'a>(
/// Inserts a favorite in the local database, if a matching Title exists.
/// Returns the matching Title if successful, otherwise an error.
-pub fn insert_favorite(title_mirabelid: i32) -> Result
{
+pub fn add_favorite(title_mirabelid: i32) -> Result {
let connection = &mut crud::establish_connection()?;
// search for a matching title, and return error if not found
@@ -58,9 +58,9 @@ pub fn insert_favorite(title_mirabelid: i32) -> Result {
}
}
-/// Searches for a titre with a keyword and returns the found Title instances.
-pub fn search_titre(keyword: &str) -> Result, DatabaseError> {
+/// Searches for a Title with a 'titre' and returns the found Title instances.
+pub fn search_title_from_titre(keyword: &str) -> Result, DatabaseError> {
let connection = &mut crud::establish_connection()?;
- crud::search_titre_from_keyword(connection, keyword)
+ crud::search_title_from_titre(connection, keyword)
}
diff --git a/src/database/crud.rs b/src/database/crud.rs
index f169395..05dd87d 100644
--- a/src/database/crud.rs
+++ b/src/database/crud.rs
@@ -71,7 +71,7 @@ pub(super) fn search_favorite_from_mirabelid(
}
/// Searches the title table for a 'titre', and returns a vector of Title items.
-pub(super) fn search_titre_from_keyword(
+pub(super) fn search_title_from_titre(
connection: &mut PgConnection,
keyword: &str,
) -> Result, DatabaseError> {
diff --git a/src/ear.rs b/src/ear.rs
index 88561fe..67dbcc1 100644
--- a/src/ear.rs
+++ b/src/ear.rs
@@ -101,7 +101,7 @@ fn parse_uri(full_request: &str) -> Result {
fn handle_request(request: Request, mut sender: Mouth) {
match request.method.as_str() {
"GET" => match request.section.as_str() {
- "titre" => match database::search_titre(&request.requested_data) {
+ "titre" => match database::search_title_from_titre(&request.requested_data) {
Ok(result) => {
if result.len() == 0 {
sender.send_data(Status::NotFound, serde_json::json!(result));
@@ -129,7 +129,7 @@ fn handle_request(request: Request, mut sender: Mouth) {
return;
},
};
- match database::insert_favorite(mirabelid) {
+ match database::add_favorite(mirabelid) {
Ok(result) => sender.send_data(Status::OK, serde_json::json!(format!("Favori inséré avec succès : {}", result.titre))),
Err(err) => match err {
database::DatabaseError::NotFound => sender.send_data(Status::NotFound, serde_json::json!(format!("{}", err))),