From f818262effa3ecccc9551c80e84547de61b7190e Mon Sep 17 00:00:00 2001 From: Adam Wisher <37659188+mrwish7@users.noreply.github.com> Date: Thu, 15 May 2025 09:08:24 +0100 Subject: [PATCH] Cached database tidy up Tidy up changes to just include the cached db functionality and TX ID algo 3 addition ready for pull --- server/datahandler.js | 3 +-- server/endpoints.js | 2 +- server/tx_search.js | 8 ++++---- web/index.ejs | 2 +- web/js/main.js | 1 - 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/server/datahandler.js b/server/datahandler.js index 1f4af93..7d54f1a 100644 --- a/server/datahandler.js +++ b/server/datahandler.js @@ -416,8 +416,7 @@ function handleData(wss, receivedData, rdsWss) { azi: currentTx.azimuth, id: currentTx.id, pi: currentTx.pi, - reg: currentTx.reg, - otherMatches: currentTx.others + reg: currentTx.reg }; } }) diff --git a/server/endpoints.js b/server/endpoints.js index fabc411..af3f429 100644 --- a/server/endpoints.js +++ b/server/endpoints.js @@ -416,7 +416,7 @@ router.get('/log_fmlist', (req, res) => { client: { request_ip: clientIp }, - type: req.query.type ? req.query.type : 'tropo', + type: (req.query.type && dataHandler.dataToSend.txInfo.dist > 700) ? req.query.type : 'tropo', log_msg: "Logged PS: " + dataHandler.dataToSend.ps.replace(/\s+/g, '_') + ", PI: " + dataHandler.dataToSend.pi + ", Signal: " + (dataHandler.dataToSend.sig - 11.25).toFixed(0) + " dBµV", }); diff --git a/server/tx_search.js b/server/tx_search.js index b5556e9..4cca38b 100644 --- a/server/tx_search.js +++ b/server/tx_search.js @@ -149,10 +149,10 @@ function evaluateStation(station) { return score; } -// Fetch data from maps +// Fetch data from cached database async function fetchTx(freq, piCode, rdsPs) { let match = null; - let multiMatches = []; + // let multiMatches = []; const now = Date.now(); freq = parseFloat(freq); @@ -192,7 +192,7 @@ async function fetchTx(freq, piCode, rdsPs) { loc.score = evaluateStation(loc); } match = filteredLocations.reduce((max, obj) => obj.score > max.score ? obj : max, filteredLocations[0]); - multiMatches = filteredLocations.filter(obj => obj !== match); + // multiMatches = filteredLocations.filter(obj => obj !== match); } else if (filteredLocations.length === 1) { match = filteredLocations[0]; } @@ -218,7 +218,7 @@ async function fetchTx(freq, piCode, rdsPs) { pi: match.pi, foundStation: true, reg: match.detectedByPireg, - others: multiMatches.length, + // others: multiMatches, }; } else { return Promise.resolve(); diff --git a/web/index.ejs b/web/index.ejs index 6311fa5..df37edf 100644 --- a/web/index.ejs +++ b/web/index.ejs @@ -287,7 +287,7 @@ [] - kW [] + kW [] diff --git a/web/js/main.js b/web/js/main.js index 392b215..5a121ac 100644 --- a/web/js/main.js +++ b/web/js/main.js @@ -976,7 +976,6 @@ const updateDataElements = throttle(function(parsedData) { updateTextIfChanged($('#data-station-itu'), parsedData.txInfo.itu); updateTextIfChanged($('#data-station-pol'), parsedData.txInfo.pol); updateHtmlIfChanged($('#data-station-azimuth'), parsedData.txInfo.azi + '°'); - updateHtmlIfChanged($('#data-station-others'), parsedData.txInfo.otherMatches > 0 ? ('+' + parsedData.txInfo.otherMatches +'') : ''); const txDistance = localStorage.getItem('imperialUnits') == "true" ? (Number(parsedData.txInfo.dist) * 0.621371192).toFixed(0) + " mi" : parsedData.txInfo.dist + " km"; updateTextIfChanged($('#data-station-distance'), txDistance); $dataStationContainer.css('display', 'block');