[Search] Cleanup

Updated documentation. Removed most unused funtions.
Removed references to the search service in the
search template -- necissary functions added to
the search controller.
(Search in a 'working' state again.)
This commit is contained in:
shale 2015-07-27 13:16:15 -07:00
parent a3977a18f0
commit 7cac858697
3 changed files with 19 additions and 50 deletions

View File

@ -21,7 +21,6 @@
--> -->
<div class="search" <div class="search"
ng-controller="SearchController as controller"> ng-controller="SearchController as controller">
<!-- Using search service as 'service' -->
<!-- Search bar input --> <!-- Search bar input -->
<div> <div>
@ -50,8 +49,8 @@
<!-- Loading icon --> <!-- Loading icon -->
<div class="load-icon" <div class="load-icon"
ng-class="{loading: service.isLoading()}" ng-class="{loading: controller.isLoading()}"
ng-if="service.isLoading()"> ng-if="controller.isLoading()">
<span class="icon wait-spinner"></span> <span class="icon wait-spinner"></span>
<span class="title-label">Loading...</span> <span class="title-label">Loading...</span>
</div> </div>

View File

@ -44,8 +44,7 @@ define(
var latestMergedResults = [], var latestMergedResults = [],
lastMergeTimestamps = [], lastMergeTimestamps = [],
lastQueryTimestamp = 0, lastQueryTimestamp = 0,
loading, loading;
aggregator = {};
// Remove duplicate objects that have the same ID // Remove duplicate objects that have the same ID
function filterRepeats(results) { function filterRepeats(results) {
@ -125,16 +124,15 @@ define(
// After all that is done, now replace latestMergedResults with this // After all that is done, now replace latestMergedResults with this
latestMergedResults = newerResults; latestMergedResults = newerResults;
lastMergeTimestamps = providerTimestamps; lastMergeTimestamps = providerTimestamps;
aggregator.latestResults = latestMergedResults;
} }
// Refresh // For documentation, see refresh below.
function refresh(callback) { function refresh(callback) {
// We are loading results // We are loading results
loading = true; loading = true;
// Get the results // Get the results
//$scope.results = searchService.getLatestResults(0, numResults); callback(latestMergedResults);
// Check to make sure that these results are the latest ones // Check to make sure that these results are the latest ones
function waitForLatest() { function waitForLatest() {
@ -148,7 +146,6 @@ define(
} else { } else {
// We got the latest results now (and done loading) // We got the latest results now (and done loading)
loading = false; loading = false;
//$scope.results = searchService.getLatestResults(0, numResults);
callback(latestMergedResults); callback(latestMergedResults);
} }
} }
@ -178,12 +175,14 @@ define(
refresh(callback); refresh(callback);
} }
aggregator = { return {
/** /**
* Sends a query to each of the providers, then updates the global * Sends a query to each of the providers, then updates the global
* latestMergedResults accordingly. * latestMergedResults accordingly.
* *
* @param inputText The text input that is the query. * @param inputText The text input that is the query.
* @param callback A callback funtion which is a setter for the
* results list, setting something for the user of this service.
* @param timestamp (optional) The time at which this function * @param timestamp (optional) The time at which this function
* was called. This timestamp will be associated with the * was called. This timestamp will be associated with the
* latest results list, which allows us to see if it has been * latest results list, which allows us to see if it has been
@ -192,14 +191,12 @@ define(
sendQuery: queryAll, sendQuery: queryAll,
/** /**
* Updates the global latestMergedResults and lastMergeTimestamps * Repeatedly updates the latest results until those results are
* by checking the latest results of each of the providers. * recent enough to correspond to the most recent query made.
*
* @param callback A callback funtion which is a setter for the
* results list, originally passed by the user of this service.
*/ */
/*
updateResults: updateResults,
*/
// Maybe replaces updateResults
refresh: refresh, refresh: refresh,
/** /**
@ -213,32 +210,9 @@ define(
* which to stop getting results. * which to stop getting results.
*/ */
getLatestResults: function (start, stop) { getLatestResults: function (start, stop) {
// TODO: Make sure that slice handles out of bounds
// By default if there are no start or stop provided, will return
// the entire thing.
return latestMergedResults.slice(start, stop); return latestMergedResults.slice(start, stop);
}, },
/**
* An array containing the latest search results that have been
* calculated. The format of the returned objects are searchResult
* objects, which have the members id, object, and score. This
* array is updated often.
*/
/*
latestResults: latestMergedResults,
*/
/**
* Get the timestamps for each of the provider's last controbutions
* to the latestMergedResults.
*/
/*
getLatestTimestamps: function () {
return lastMergeTimestamps;
},
*/
/** /**
* Get the number of search results that have been calculated most * Get the number of search results that have been calculated most
* recently. * recently.
@ -247,12 +221,14 @@ define(
return latestMergedResults.length; return latestMergedResults.length;
}, },
/**
* Checks to see if we are still waiting for the results to be
* fully updated.
*/
isLoading: function () { isLoading: function () {
return loading; return loading;
} }
}; };
return aggregator;
} }
return SearchAggregator; return SearchAggregator;

View File

@ -34,11 +34,6 @@ define(function () {
// Starting amount of results to load. Will get increased. // Starting amount of results to load. Will get increased.
var numResults = INITIAL_LOAD_NUMBER; var numResults = INITIAL_LOAD_NUMBER;
// This allows us to directly access the search aggregator's members.
// Most important is latestResults, which is continuously updated. This
// means that this controller does not have to poll for results any more.
$scope.service = searchService;
// Function to be passed to the search service which allows it to set the // Function to be passed to the search service which allows it to set the
// search template's results list // search template's results list
function setControllerResults(results) { function setControllerResults(results) {
@ -65,7 +60,7 @@ define(function () {
return { return {
/** /**
* Search the filetree. * Search the filetree.
* Assumes that there will be search text in ngModel.input * Assumes that any search text will be in ngModel.input
*/ */
search: search, search: search,
@ -84,10 +79,9 @@ define(function () {
* Checks to see if we are still waiting for the results to be * Checks to see if we are still waiting for the results to be
* fully updated. * fully updated.
*/ */
/*
isLoading: function () { isLoading: function () {
return searchService.isLoading(); return searchService.isLoading();
},*/ },
/** /**
* Checks to see if there are more search results to display. * Checks to see if there are more search results to display.