Skip to content

Commit 0120409

Browse files
Merge pull request #1 from AndreasK79/new_api_fix
2 parents 4d8ce9c + 973a713 commit 0120409

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

getwavelogdatatoiobroker_new_wp_api.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function runScript() {
1414
body: {
1515
key: API_KEY,
1616
station_id: STATION_PROFILE_ID,
17-
fetchfromid: 0
1817
},
1918
timeout: 15000
2019
};
@@ -30,16 +29,34 @@ function runScript() {
3029
}
3130

3231
// The new API now returns pre-aggregated QSO statistics.
33-
const totalQso = body.total_qso;
34-
const totalQsoYear = body.total_qso_year;
35-
const ssbCount = body.ssb_qso;
36-
const fmCount = body.fm_qso;
37-
const rttyCount = body.rtty_qso;
38-
const ft8ft4Count = body.ft8ft4_qso;
39-
const pskCount = body.psk_qso;
40-
const cwCount = body.cw_qso;
41-
const js8Count = body.js8_qso;
42-
const digiCount = body.digi_qso;
32+
let totalQso = body.statistics.totalalltime[0].count;
33+
let totalQsoYear = body.statistics.totalthisyear[0].count;
34+
let ssbCount = 0, fmCount = 0, rttyCount = 0, ft8ft4Count = 0;
35+
let pskCount = 0, cwCount = 0, js8Count = 0, digiCount = 0;
36+
37+
const digi_modes = ['FT8', 'FT4', 'PSK', 'RTTY', 'JS8', 'JT65', 'JT9', 'OLIVIA', 'CONTESTI', 'ROS']; // Add more as needed
38+
39+
if (body.statistics.totalgroupedmodes) {
40+
body.statistics.totalgroupedmodes.forEach(mode => {
41+
const col_mode = mode.col_mode;
42+
const col_submode = mode.col_submode || '';
43+
44+
if (col_mode === 'SSB') ssbCount += Number(mode.count);
45+
if (col_mode === 'FM') fmCount += Number(mode.count);
46+
if (col_mode === 'RTTY') rttyCount += Number(mode.count);
47+
if (col_mode === 'CW') cwCount += Number(mode.count);
48+
if (col_mode === 'PSK' || col_submode.startsWith('PSK')) pskCount += Number(mode.count);
49+
if (col_mode === 'JS8') js8Count += Number(mode.count);
50+
if (col_mode === 'FT8' || col_submode === 'FT4') ft8ft4Count += Number(mode.count);
51+
52+
// Digital modes total
53+
digi_modes.forEach(digi => {
54+
if (col_mode.startsWith(digi) || col_submode.startsWith(digi)) {
55+
digiCount += Number(mode.count);
56+
}
57+
});
58+
});
59+
}
4360

4461
console.log(`Total QSOs: ${totalQso}, This Year: ${totalQsoYear}, SSB: ${ssbCount}, FM: ${fmCount}, RTTY: ${rttyCount}, FT8+FT4: ${ft8ft4Count}, PSK: ${pskCount}, CW: ${cwCount}, JS8: ${js8Count}, Digi: ${digiCount}`);
4562

0 commit comments

Comments
 (0)