Skip to content

Commit

Permalink
[#1792] Get only distinct values from the datastore
Browse files Browse the repository at this point in the history
This code depends on code from pull request #1815.
  • Loading branch information
vitorbaptista committed Jul 8, 2014
1 parent 4c9db50 commit d0b96fb
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ckan/public/base/javascript/modules/resource-view-filters.js
Expand Up @@ -108,22 +108,20 @@ this.ckan.module('resource-view-filters', function (jQuery, _) {
limit: queryLimit + 1,
offset: offset,
fields: filterName,
distinct: true,
sort: filterName
};
},
results: function (data, page) {
var uniqueResults = {},
results = data.result.records.slice(0, queryLimit),
var slicedData = data.result.records.slice(0, queryLimit),
hasMore = (data.result.records.length == queryLimit + 1),
theData;
$.each(results, function (i, record) {
uniqueResults[record[filterName]] = true;
});
theData = $.map(Object.keys(uniqueResults), function (record) {
return { id: record, text: record };
results;

results = $.map(slicedData, function (record) {
return { id: record[filterName], text: record[filterName] };
});

return { results: theData, more: hasMore };
return { results: results, more: hasMore };
}
},
initSelection: function (element, callback) {
Expand Down

0 comments on commit d0b96fb

Please sign in to comment.