Skip to content

Commit

Permalink
Fixed SQL error when getting total after saving record with location …
Browse files Browse the repository at this point in the history
…filter set
  • Loading branch information
Mattk70 committed Mar 9, 2024
1 parent 5b07eee commit 840ccb8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
12 changes: 6 additions & 6 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const originalError = console.error;
function customURLEncode(str) {
return encodeURIComponent(str)
.replace(/[!'()*]/g, (c) => {
// Replacing additional characters manually
// Replacing additional characters not handled by encodeURIComponent
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
})
.replace(/%20/g, '+'); // Optionally replace space with '+' instead of '%20'
.replace(/%20/g, '+'); // Replace space with '+' instead of '%20'
}

// Override console.warn to intercept and track warnings
Expand All @@ -23,7 +23,7 @@ console.warn = function(message) {
originalWarn.apply(console, arguments);

// Track the warning message using your tracking function
track('Warnings', arguments[0], encodeURIComponent(arguments[1]));
track('Warnings', arguments[0], customURLEncode(arguments[1]));
};

// Override console.error to intercept and track errors
Expand All @@ -32,7 +32,7 @@ console.error = function(message) {
originalError.apply(console, arguments);

// Track the error message using your tracking function
track('Errors', arguments[0], encodeURIComponent(arguments[1]));
track('Errors', arguments[0], customURLEncode(arguments[1]));
};


Expand All @@ -42,7 +42,7 @@ window.addEventListener('unhandledrejection', function(event) {
const stackTrace = event.reason.stack;

// Track the unhandled promise rejection
track('Unhandled UI Promise Rejection', errorMessage, encodeURIComponent(stackTrace));
track('Unhandled UI Promise Rejection', errorMessage, customURLEncode(stackTrace));
});

window.addEventListener('rejectionhandled', function(event) {
Expand All @@ -51,7 +51,7 @@ window.addEventListener('rejectionhandled', function(event) {
const stackTrace = event.reason.stack;

// Track the unhandled promise rejection
track('Handled UI Promise Rejection', errorMessage, encodeURIComponent(stackTrace));
track('Handled UI Promise Rejection', errorMessage, customURLEncode(stackTrace));
});

const STATE = {
Expand Down
34 changes: 22 additions & 12 deletions js/worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ID_SITE = 2;
const ID_SITE = 3;


const { ipcRenderer } = require('electron');
Expand All @@ -23,13 +23,22 @@ const { PassThrough } = require('node:stream');
const originalWarn = console.warn;
const originalError = console.error;

function customURLEncode(str) {
return encodeURIComponent(str)
.replace(/[!'()*]/g, (c) => {
// Replacing additional characters not handled by encodeURIComponent
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
})
.replace(/%20/g, '+'); // Replace space with '+' instead of '%20'
}

// Override console.warn to intercept and track warnings
console.warn = function(message) {
// Call the original console.warn to maintain default behavior
originalWarn.apply(console, arguments);

// Track the warning message using your tracking function
track('Warnings', arguments[0], encodeURIComponent(arguments[1]));
track('Warnings', arguments[0], customURLEncode(arguments[1]));
};

// Override console.error to intercept and track errors
Expand All @@ -38,31 +47,31 @@ console.error = function(message) {
originalError.apply(console, arguments);

// Track the error message using your tracking function
track('Handled Errors', arguments[0], encodeURIComponent(arguments[1]));
track('Handled Errors', arguments[0], customURLEncode(arguments[1]));
};
// Implement error handling in the worker
self.onerror = function(message, file, lineno, colno, error) {
track('Unhandled Worker Error', error.message, encodeURIComponent(error.stack));
track('Unhandled Worker Error', error.message, customURLEncode(error.stack));
// Return false not to inhibit the default error handling
return false;
};

self.addEventListener('unhandledrejection', function(event) {
// Extract the error message and stack trace from the event
const errorMessage = event.reason.message;
const stackTrace = event.reason.stack;
const errorMessage = event.reason?.message;
const stackTrace = event.reason?.stack;

// Track the unhandled promise rejection
track('Unhandled Worker Promise Rejections', errorMessage, encodeURIComponent(stackTrace));
track('Unhandled Worker Promise Rejections', errorMessage, customURLEncode(stackTrace));
});

self.addEventListener('rejectionhandled', function(event) {
// Extract the error message and stack trace from the event
const errorMessage = event.reason.message;
const stackTrace = event.reason.stack;
const errorMessage = event.reason?.message;
const stackTrace = event.reason?.stack;

// Track the unhandled promise rejection
track('Handled Worker Promise Rejections', errorMessage, encodeURIComponent(stackTrace));
track('Handled Worker Promise Rejections', errorMessage, customURLEncode(stackTrace));
});

//Object will hold files in the diskDB, and the active timestamp from the most recent selection analysis.
Expand Down Expand Up @@ -670,7 +679,8 @@ const prepSummaryStatement = (included) => {
params.push(FILE_QUEUE[0])
}
if (STATE.locationID) {
resultStatement += ` AND locationID = ${STATE.locationID} `;
resultStatement += ` AND locationID = ? `;
params.push(STATE.locationID)
}
if (STATE.detect.nocmig){
resultStatement += ' AND COALESCE(isDaylight, 0) != 1 '; // Backward compatibility for < v0.9.
Expand Down Expand Up @@ -2328,7 +2338,7 @@ const prepSummaryStatement = (included) => {
params.push(...included)
}
if (STATE.locationID) {
positionStmt += ` AND locationID = ${STATE.locationID} `;
positionStmt += ` AND locationID = ? `;
params.push(STATE.locationID)
}
if (STATE.detect.nocmig){
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chirpity",
"version": "1.5.1",
"version": "1.5.2",
"description": "Chirpity Nocmig",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -144,7 +144,8 @@
]
},
"nsis": {
"deleteAppDataOnUninstall": true
"deleteAppDataOnUninstall": true,
"perMachine": true
},
"win": {
"publish": [
Expand Down

0 comments on commit 840ccb8

Please sign in to comment.