Skip to content

Commit

Permalink
Finally fixed the confidence slider so it never disapepears on you!
Browse files Browse the repository at this point in the history
NO indexes on the databases
  • Loading branch information
Mattk70 committed Nov 21, 2023
1 parent c73d9e7 commit ab9e205
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
25 changes: 9 additions & 16 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3509,27 +3509,19 @@ const setConfidence = (e) => {
handleThresholdChange(e);
}

thresholdDisplay.addEventListener('click', () => {
confidenceSliderDisplay.classList.remove('d-none');
confidenceTimerTimeout = setTimeout(hideConfidenceSlider, 1750)
thresholdDisplay.addEventListener('click', (e) => {
e.stopPropagation();
confidenceSliderDisplay.classList.toggle('d-none');
// confidenceTimerTimeout = setTimeout(hideConfidenceSlider, 1750)
})
confidenceSlider.addEventListener('click', (e) => {
e.stopPropagation();
})

const hideConfidenceSlider = () => {
confidenceSliderDisplay.classList.add('d-none');
}
let confidenceTimerTimeout;
confidenceSliderDisplay.addEventListener('mouseout', () => {
confidenceTimerTimeout = setTimeout(hideConfidenceSlider, 3000)
})
confidenceSliderDisplay.addEventListener('change', setConfidence);

confidenceSliderDisplay.addEventListener('mouseenter', () => {
if (confidenceTimerTimeout) clearTimeout(confidenceTimerTimeout)
})

confidenceSliderDisplay.addEventListener('input', setConfidence);
confidenceSliderDisplay.addEventListener('mouseup', (e) => {
hideConfidenceSlider()
});

function showThreshold(threshold) {
thresholdDisplay.innerHTML = `<b>${threshold}%</b>`;
Expand Down Expand Up @@ -3728,6 +3720,7 @@ function getSnameFromCname(cname) {

$(document).on('click', function () {
$("#context-menu").removeClass("show").hide();
hideConfidenceSlider();
})

async function createContextMenu(e) {
Expand Down
31 changes: 15 additions & 16 deletions js/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ const createDB = async (file) => {
UNIQUE (day, fileID),
CONSTRAINT fk_files
FOREIGN KEY (fileID) REFERENCES files(id) ON DELETE CASCADE)`);
await db.runAsync('CREATE INDEX idx_datetime ON records(dateTime)');
await db.runAsync('CREATE INDEX idx_species ON records(speciesID)');
await db.runAsync('CREATE INDEX idx_files ON records(fileID)');
// await db.runAsync('CREATE INDEX idx_datetime ON records(dateTime)');
// await db.runAsync('CREATE INDEX idx_species ON records(speciesID)');
// await db.runAsync('CREATE INDEX idx_files ON records(fileID)');
if (archiveMode) {
for (let i = 0; i < LABELS.length; i++) {
const [sname, cname] = LABELS[i].replaceAll("'", "''").split('_');
Expand Down Expand Up @@ -131,11 +131,10 @@ async function loadDB(path) {
await diskDB.runAsync('ALTER TABLE records ADD COLUMN isDaylight INTEGER')
console.log('Added isDaylight column to records table')
}
const datetime = diskDB.runAsync('CREATE INDEX IF NOT EXISTS idx_datetime ON records(dateTime)');
const covering_total = diskDB.runAsync('CREATE INDEX IF NOT EXISTS idx_covering_total ON records (confidence, isDaylight)');
const species = diskDB.runAsync('CREATE INDEX IF NOT EXISTS idx_species ON records(speciesID)');
const files = diskDB.runAsync('CREATE INDEX IF NOT EXISTS idx_files ON records(fileID)');
await Promise.all([datetime, species, files, covering_total]);
// const datetime = diskDB.runAsync('CREATE INDEX IF NOT EXISTS idx_datetime ON records (dateTime)');
// const covering_total = diskDB.runAsync('CREATE INDEX IF NOT EXISTS idx_covering_total ON records (confidence, isDaylight)');
// const species = diskDB.runAsync('CREATE INDEX IF NOT EXISTS idx_species ON records (speciesID)');
//await Promise.all([datetime, species, files, covering_total]);
console.log("Opened and cleaned disk db " + file)
}
return true
Expand Down Expand Up @@ -275,7 +274,7 @@ async function handleMessage(e) {
const t1 = Date.now()
await getTotal(args);
//await Promise.all([getResults(args), getSummary(args)]);
DEBUG && console.log('Filter took ', (Date.now() - t0) / 1000, 'seconds', '\nGettotal took ', (Date.now() - t1) / 1000, 'seconds',)
console.log('Filter took ', (Date.now() - t0) / 1000, 'seconds', '\nGettotal took ', (Date.now() - t1) / 1000, 'seconds',)

}
break;
Expand Down Expand Up @@ -491,9 +490,9 @@ const getTotal = async ({species = undefined, offset = 0}) => {
const useRange = range?.start;
let SQL = ` WITH MaxConfidencePerDateTime AS (
SELECT confidence FROM records `;
if (['analyse', 'archive'].includes(STATE.mode)) {
SQL += ' JOIN files on files.id = records.fileid ';
}
// if (['analyse', 'archive'].includes(STATE.mode)) {
// SQL += ' JOIN files on files.id = records.fileid ';
// }
SQL += ` WHERE confidence >= ${STATE.detect.confidence} `;
if (species) {
params.push(species);
Expand All @@ -503,10 +502,10 @@ const getTotal = async ({species = undefined, offset = 0}) => {
if (useRange) SQL += ` AND dateTime BETWEEN ${range.start} AND ${range.start} `;
if (STATE.detect.nocmig) SQL += ' AND COALESCE(isDaylight, 0) != 1 ';
if (STATE.locationID) SQL += ` AND locationID = ${STATE.locationID}`;
if (['analyse', 'archive'].includes(STATE.mode)) {
SQL += ` AND name IN (${prepParams(STATE.filesToAnalyse)}) `;
params.push(...STATE.filesToAnalyse)
}
// if (['analyse', 'archive'].includes(STATE.mode)) {
// SQL += ` AND name IN (${prepParams(STATE.filesToAnalyse)}) `;
// params.push(...STATE.filesToAnalyse)
// }
SQL += ' ) '
SQL += `SELECT COUNT(confidence) AS total FROM MaxConfidencePerDateTime`;

Expand Down

0 comments on commit ab9e205

Please sign in to comment.