Skip to content

Commit 3ba1a81

Browse files
committed
Bug Fix: Change default job search sort to start date (primary key), for performance.
1 parent 9df9029 commit 3ba1a81

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

htdocs/js/pages/Search.class.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ Page.Search = class Search extends Page.PageUtils {
235235
// sort
236236
html += '<div class="form_cell">';
237237
var sort_items = [
238+
{ id: 'id_desc', title: 'Newest on Top', icon: 'sort-descending', group: 'Start Date:' },
239+
{ id: 'id_asc', title: 'Oldest on Top', icon: 'sort-ascending' },
240+
238241
{ id: 'date_desc', title: 'Newest on Top', icon: 'sort-descending', group: 'Completion Date:' },
239242
{ id: 'date_asc', title: 'Oldest on Top', icon: 'sort-ascending' },
240243

@@ -370,7 +373,7 @@ Page.Search = class Search extends Page.PageUtils {
370373
}
371374

372375
var sort = this.div.find('#fe_s_sort').val();
373-
if (sort != 'date_desc') args.sort = sort;
376+
if (sort != 'id_desc') args.sort = sort;
374377

375378
if (!num_keys(args)) return null;
376379

@@ -442,6 +445,16 @@ Page.Search = class Search extends Page.PageUtils {
442445
compact: 1
443446
};
444447
switch (args.sort) {
448+
case 'id_asc':
449+
sopts.sort_by = '_id';
450+
sopts.sort_dir = 1;
451+
break;
452+
453+
case 'id_desc':
454+
sopts.sort_by = '_id';
455+
sopts.sort_dir = -1;
456+
break;
457+
445458
case 'date_asc':
446459
sopts.sort_by = 'completed';
447460
sopts.sort_dir = 1;
@@ -720,6 +733,16 @@ Page.Search = class Search extends Page.PageUtils {
720733
var title = 'Bulk Export Jobs';
721734

722735
switch (args.sort) {
736+
case 'id_asc':
737+
sopts.sort_by = '_id';
738+
sopts.sort_dir = 1;
739+
break;
740+
741+
case 'id_desc':
742+
sopts.sort_by = '_id';
743+
sopts.sort_dir = -1;
744+
break;
745+
723746
case 'date_asc':
724747
sopts.sort_by = 'completed';
725748
sopts.sort_dir = 1;

htdocs/js/pages/ServerUtils.class.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,8 +2219,6 @@ Page.ServerUtils = class ServerUtils extends Page.PageUtils {
22192219

22202220
args.offset = args.offset || 0;
22212221
args.limit = config.alt_items_per_page;
2222-
args.sort_by = 'completed';
2223-
args.sort_dir = -1;
22242222

22252223
// add epoch date range (don't use .. range shorthand because end is inclusive)
22262224
args.query += ' date:>=' + this.epochStart + ' date:<' + this.epochEnd;

lib/api/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Search {
2424
params.offset = parseInt( params.offset || 0 );
2525
params.limit = parseInt( params.limit || 1 );
2626

27-
if (!params.sort_by) params.sort_by = 'completed';
27+
if (!params.sort_by) params.sort_by = '_id';
2828
if (!params.sort_dir) params.sort_dir = -1;
2929

3030
this.loadSession(args, function (err, session, user) {

0 commit comments

Comments
 (0)