[Search] Needs more updating

The search aggregator now correctly gets
from the providers, but because of not
sync, the display is effectively one press
behind the correct search results.
Still, working to some extent.
This commit is contained in:
shale 2015-07-21 12:59:52 -07:00
parent a5febf8f0f
commit f0f396f656
3 changed files with 27 additions and 7 deletions

View File

@ -126,6 +126,7 @@ define(
return results;
}
/*
// 'Loop' over the promises using recursion so that the promises are fufilled by the
// time that we are done
function getPromisedResults(resultsPromises, promiseIndex, finalResults) {
@ -138,6 +139,23 @@ define(
});
}
}
*/
function updateResults() {
var newerResults = [];
// For each provider, get its most recent results
for (var i = 0; i < providers.length; i += 1) {
newerResults = newerResults.concat(providers[i].getLatest());
}
// Clean up
newerResults = filterRepeats(newerResults);
newerResults = orderByScore(newerResults);
// After all that is done, now replace latestMergedResults with this
latestMergedResults = newerResults;
}
// Calls the searches of each of the providers, then
// merges the results lists so that there are not redundant
@ -146,14 +164,14 @@ define(
*
*/
function queryAll(inputID) {
var resultsPromises = [],
var promises = [],
date = new Date(),
timestamp = date.getTime();
// Get result list promises
// TODO: This is now 'Send the query to all the providers'
for (var i = 0; i < providers.length; i += 1) {
resultsPromises.push(
promises.push(
providers[i].query(
inputID, timestamp, DEFAULT_MAX_RESULTS, DEFUALT_TIMEOUT
)
@ -163,17 +181,18 @@ define(
// And then we might also want to check to see if the timestamp
// is correct.
//var newerResults = [];
updateResults();
/*
// Wait for the promises to fufill
return getPromisedResults(resultsPromises, 0, []).then(function (c) {
return getPromisedResults(promises, 0, []).then(function (c) {
// Get rid of the repeated objects and put in correct order
c = filterRepeats(c);
c = orderByScore(c);
latestMergedResults = c;
return c;
});
*/
}
// TODO: getLatestResults(start, stop) so you can choose which indicies to start and stop

View File

@ -36,9 +36,9 @@ define(function () {
// Will need to compile search result list (for this
// result page) here, using pseudo linkedlist searchResult
searchService.sendQuery(inputID).then(function (c) {
searchService.sendQuery(inputID);/*.then(function (c) {
//$scope.results = c;
});
});*/
$scope.results = searchService.getLatestResults(0, 5);
console.log('$scope results', $scope.results);
}

View File

@ -143,6 +143,7 @@
self.onmessage = function (event) {
console.log('webworker onmessage');
if (event.data.request === 'index') {
// TODO: Don't really need to post here.
self.postMessage(index(event.data));
} else if (event.data.request === 'search') {
self.postMessage(search(event.data));