Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #58 from honeypotio/ignored-talents
Browse files Browse the repository at this point in the history
resources/talent: allow ignored_talents[] and rename key for bookmarks
  • Loading branch information
kdamball authored Feb 6, 2018
2 parents 0f93f1d + ccc7994 commit 171ede4
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/resources/talent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl Talent {
"current_location", &vec_from_params!(params, "current_location")),

<Query as VectorOfTerms<i32>>::build_terms(
"id", &vec_from_params!(params, "ids")),
"id", &vec_from_params!(params, "bookmarked_talents")),

Talent::visibility_filters(epoch,
i32_vec_from_params!(params, "presented_talents"),
Expand All @@ -256,7 +256,10 @@ impl Talent {
"blocked_companies", &company_id),

<Query as VectorOfTerms<i32>>::build_terms(
"id", &vec_from_params!(params, "contacted_talents"))
"id", &vec_from_params!(params, "contacted_talents")),

<Query as VectorOfTerms<i32>>::build_terms(
"id", &vec_from_params!(params, "ignored_talents")),
].into_iter()
.flat_map(|x| x)
.collect::<Vec<Query>>())
Expand Down Expand Up @@ -1065,6 +1068,16 @@ mod tests {
assert_eq!(vec![1, 4], results.ids());
}

// Ignoring some talents
{
let mut params = Map::new();
params.assign("keywords", Value::String("database admin".to_owned())).unwrap();
params.assign("ignored_talents[]", Value::U64(1)).unwrap();

let results = Talent::search(&mut client, &*index, &params);
assert_eq!(vec![4], results.ids());
}

// highlight
{
let mut params = Map::new();
Expand All @@ -1087,14 +1100,14 @@ mod tests {
// filtering for given bookmarks (ids)
{
let mut params = Map::new();
params.assign("ids[]", Value::U64(2)).unwrap();
params.assign("ids[]", Value::U64(4)).unwrap();
params.assign("ids[]", Value::U64(1)).unwrap();
params.assign("ids[]", Value::U64(3)).unwrap();
params.assign("ids[]", Value::U64(5)).unwrap();
params.assign("ids[]", Value::U64(6)).unwrap();
params.assign("ids[]", Value::U64(7)).unwrap();
params.assign("ids[]", Value::U64(8)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(2)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(4)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(1)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(3)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(5)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(6)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(7)).unwrap();
params.assign("bookmarked_talents[]", Value::U64(8)).unwrap();

let results = Talent::search(&mut client, &*index, &params);
assert_eq!(vec![4, 5, 2, 1], results.ids());
Expand Down

0 comments on commit 171ede4

Please sign in to comment.