From 266df1dbe661600307783fa8cbdfb2ed30a759d4 Mon Sep 17 00:00:00 2001 From: Mattk70 Date: Fri, 15 Dec 2023 17:01:25 +0000 Subject: [PATCH] more results sort and SQl fixes --- js/ui.js | 3 ++- js/worker.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/ui.js b/js/ui.js index 67c333a6..36d96665 100644 --- a/js/ui.js +++ b/js/ui.js @@ -2082,6 +2082,7 @@ listIcon.addEventListener('click', () => { listToUse.value = keys[replace]; config.list = keys[replace]; updatePrefs(); + resetResults({clearSummary: true, clearPagination: true, clearResults: true}); worker.postMessage({ action: 'update-list', list: config.list }) break } @@ -3319,7 +3320,7 @@ confidenceSort.addEventListener('click', () => { const timeSort = document.querySelectorAll('.time-sort'); timeSort.forEach(el => { el.addEventListener('click', () => { - setSortOrder('dateTime') + setSortOrder('timestamp') }); }) diff --git a/js/worker.js b/js/worker.js index e0963ba3..05bc80ff 100644 --- a/js/worker.js +++ b/js/worker.js @@ -514,9 +514,10 @@ const getResultsParams = (species, confidence, offset, limit, topRankin) => { ['analyse', 'archive'].includes(STATE.mode) && !STATE.selection && params.push(...STATE.filesToAnalyse); const blocked = (STATE.blocked.length && !STATE.selection) ? STATE.blocked : []; blocked.length && params.push(...blocked); - limit !== Infinity && params.push(limit, offset); + params.push(topRankin); species && params.push(species); + limit !== Infinity && params.push(limit, offset); return params } @@ -568,12 +569,11 @@ const prepResultsStatement = (species, noLimit) => { if (STATE.detect.nocmig){ resultStatement += ' AND COALESCE(isDaylight, 0) != 1 '; } - const limitClause = noLimit ? '' : 'LIMIT ? OFFSET ?'; - resultStatement += ` ORDER BY ${STATE.sortOrder}, confidence DESC, callCount DESC ${limitClause} `; resultStatement += `) SELECT dateTime as timestamp, + score, duration, filestart, name as file, @@ -591,6 +591,9 @@ const prepResultsStatement = (species, noLimit) => { ranked_records WHERE confidence_rank <= ? `; if (species) resultStatement+= ` AND cname = ? `; + + const limitClause = noLimit ? '' : 'LIMIT ? OFFSET ?'; + resultStatement += ` ORDER BY ${STATE.sortOrder}, callCount DESC ${limitClause} `; STATE.GET_RESULT_SQL = STATE.db.prepare(resultStatement); }