From 98d2c5361fdcab0cfeb017f2145d3a2380dbcd87 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 16 Jul 2013 18:28:26 -0400 Subject: [PATCH] search.js: Simplify get_person_suggestions (imported from commit 44f22923a73633c5693a99ae9ce788f10cd5f505) --- zephyr/static/js/search.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/zephyr/static/js/search.js b/zephyr/static/js/search.js index 06ba18c6a3..8d5c68a86b 100644 --- a/zephyr/static/js/search.js +++ b/zephyr/static/js/search.js @@ -145,25 +145,14 @@ function get_person_suggestions(all_people, query, prefix, operator, max_num) { return person_matches_query(person, query); }); + people.sort(typeahead_helper.compare_by_pms); + people = people.slice(0, max_num); + var objs = $.map(people, function (person) { - return {query: person}; - }); - - - objs.sort(function (x, y) { - return typeahead_helper.compare_by_pms(get_query(x), get_query(y)); - }); - - objs = objs.slice(0, max_num); - - $.each(objs, function (idx, obj) { - var person; - var name; - - person = obj.query; - name = highlight_person(query, person); - obj.description = prefix + ' ' + name; - obj.search_string = operator + ':' + obj.query.email; + var name = highlight_person(query, person); + var description = prefix + ' ' + name; + var search_string = operator + ':' + person.email; + return {description: description, search_string: search_string}; }); return objs;