[Search] Clean up

This commit is contained in:
slhale 2015-08-03 11:38:47 -07:00
parent d0bad46627
commit 695582b30f
2 changed files with 8 additions and 16 deletions

View File

@ -192,11 +192,6 @@ define(
// Index the tree's contents once at the beginning // Index the tree's contents once at the beginning
getItems(); getItems();
// TODO: Is this a good assumption that the tree's contents will not
// change often enough?
// TODO: This makes the timeout parameter that query takes
// useless. See if timing out worker is an idea that works.
return { return {
/** /**

View File

@ -102,7 +102,6 @@
// Add extra to the score if the search term exists // Add extra to the score if the search term exists
// as its own term within the items // as its own term within the items
// TODO: This may be undesired
if (name.split(' ').indexOf(terms[i]) !== -1) { if (name.split(' ').indexOf(terms[i]) !== -1) {
score += 0.5; score += 0.5;
} }
@ -123,22 +122,21 @@
* * timestamp: The time identifier from when the query was made * * timestamp: The time identifier from when the query was made
*/ */
function search(data) { function search(data) {
// This results 'dictionary' will have domain object ID keys which // This results dictionary will have domain object ID keys which
// point to the domain object's score. (The score is wrt only this // point to the domain object's score.
// specific search input.)
var results = {}, var results = {},
input = data.input.toLocaleLowerCase(), input = data.input.toLocaleLowerCase(),
terms = convertToTerms(input), terms = convertToTerms(input),
i,
id,
score,
message = { message = {
request: 'search', request: 'search',
results: {}, results: {},
total: 0, total: 0,
timestamp: data.timestamp, // TODO: This may be no longer necissary timestamp: data.timestamp,
timedOut: false timedOut: false
}; },
score,
i,
id;
// If the user input is empty, we want to have no search results. // If the user input is empty, we want to have no search results.
if (input !== '') { if (input !== '') {
@ -149,6 +147,7 @@
break; break;
} }
// Score and add items
score = scoreItem(indexedItems[i], input, terms); score = scoreItem(indexedItems[i], input, terms);
if (score > 0) { if (score > 0) {
results[indexedItems[i].id] = score; results[indexedItems[i].id] = score;
@ -173,8 +172,6 @@
} }
return message; return message;
// TODO: This function is too long.
} }
self.onmessage = function (event) { self.onmessage = function (event) {