Skip to content

Commit

Permalink
Just pass a default order
Browse files Browse the repository at this point in the history
  • Loading branch information
Bargs committed Aug 29, 2017
1 parent 2b7c73e commit faba375
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function discoverController(
function getStateDefaults() {
return {
query: $scope.searchSource.get('query') || { query: '', language: config.get('search:queryLanguage') },
sort: getSort.array(savedSearch.sort, $scope.indexPattern, { order: config.get('discover:sort:defaultOrder') }),
sort: getSort.array(savedSearch.sort, $scope.indexPattern, config.get('discover:sort:defaultOrder')),
columns: savedSearch.columns.length > 0 ? savedSearch.columns : config.get('defaultColumns').slice(),
index: $scope.indexPattern.id,
interval: 'auto',
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/doc_table/lib/get_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import _ from 'lodash';
* @param {object} indexPattern used for determining default sort
* @returns {object} a sort object suitable for returning to elasticsearch
*/
export function getSort(sort, indexPattern, sortOptions = {}) {
export function getSort(sort, indexPattern, defaultSortOrder = 'desc') {
const sortObj = {};
let field;
let direction;
Expand All @@ -21,7 +21,7 @@ export function getSort(sort, indexPattern, sortOptions = {}) {
direction = sort[1];
} else if (indexPattern.timeFieldName && isSortable(indexPattern.timeFieldName)) {
field = indexPattern.timeFieldName;
direction = sortOptions.order || 'desc';
direction = defaultSortOrder;
}

if (field) {
Expand All @@ -35,7 +35,7 @@ export function getSort(sort, indexPattern, sortOptions = {}) {
return sortObj;
}

getSort.array = function (sort, indexPattern, sortOptions) {
return _(getSort(sort, indexPattern, sortOptions)).pairs().pop();
getSort.array = function (sort, indexPattern, defaultSortOrder) {
return _(getSort(sort, indexPattern, defaultSortOrder)).pairs().pop();
};

0 comments on commit faba375

Please sign in to comment.