From 43b0a8ba1f384ed9a51559c4eb84a556bec8c3c5 Mon Sep 17 00:00:00 2001 From: Giovanni Capuano Date: Thu, 25 Jan 2018 12:40:15 +0100 Subject: [PATCH 1/2] resources/talent: filter for current_location --- src/resources/talent.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/resources/talent.rs b/src/resources/talent.rs index c2f98a6..1943a8d 100644 --- a/src/resources/talent.rs +++ b/src/resources/talent.rs @@ -214,6 +214,13 @@ impl Talent { None => vec![] }, + match params.get("current_location") { + Some(&Value::String(ref current_location)) => vec![ + Query::build_term("current_location", current_location.to_string()).build() + ], + _ => vec![] + }, + vec![ Query::build_bool() .with_must( @@ -756,7 +763,7 @@ mod tests { desired_work_roles_experience: vec!["2..3".to_owned(), "5".to_owned()], professional_experience: "1..2".to_owned(), work_locations: vec!["Berlin".to_owned()], - current_location: "Berlin".to_owned(), + current_location: "Naples".to_owned(), work_authorization: "yes".to_owned(), skills: vec!["JavaScript".to_owned(), "C++".to_owned(), "Ember.js".to_owned()], summary: "C++ and frontend dev. HTML, C++, JavaScript and C#. Did I say C++?".to_owned(), @@ -1098,6 +1105,15 @@ mod tests { assert_eq!(4, results.total); } + // filtering for current_location + { + let mut params = Map::new(); + params.assign("current_location", Value::String("Naples".into())).unwrap(); + + let results = Talent::search(&mut client, &*index, ¶ms); + assert_eq!(vec![5], results.ids()); + } + // filtering for work_authorization { let mut params = Map::new(); From 8e61533c5b690b18c1980e69e632bc5f7c644766 Mon Sep 17 00:00:00 2001 From: Kado Date: Tue, 30 Jan 2018 16:56:37 +0100 Subject: [PATCH 2/2] Accept list for current location --- src/resources/talent.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/resources/talent.rs b/src/resources/talent.rs index 1943a8d..7f5f94e 100644 --- a/src/resources/talent.rs +++ b/src/resources/talent.rs @@ -214,13 +214,6 @@ impl Talent { None => vec![] }, - match params.get("current_location") { - Some(&Value::String(ref current_location)) => vec![ - Query::build_term("current_location", current_location.to_string()).build() - ], - _ => vec![] - }, - vec![ Query::build_bool() .with_must( @@ -242,6 +235,9 @@ impl Talent { >::build_terms( "work_locations", &vec_from_params!(params, "work_locations")), + >::build_terms( + "current_location", &vec_from_params!(params, "current_location")), + >::build_terms( "id", &vec_from_params!(params, "ids")), @@ -1108,7 +1104,7 @@ mod tests { // filtering for current_location { let mut params = Map::new(); - params.assign("current_location", Value::String("Naples".into())).unwrap(); + params.assign("current_location[]", Value::String("Naples".into())).unwrap(); let results = Talent::search(&mut client, &*index, ¶ms); assert_eq!(vec![5], results.ids());