Skip to content

Commit 96384f8

Browse files
authored
2.8.8
2 parents 6c6b96f + fe38b96 commit 96384f8

36 files changed

Lines changed: 2168 additions & 459 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
/application/config/config.php
33
/application/config/managed.php
44
/application/config/managed.sample.php
5+
/application/cache/*
6+
!/application/cache/index.html
7+
!/application/cache/.htaccess
58
/application/logs/*.php
69
/uploads/*.adi
710
/uploads/*.ADI

application/config/migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|
2323
*/
2424

25-
$config['migration_version'] = 244;
25+
$config['migration_version'] = 250;
2626

2727
/*
2828
|--------------------------------------------------------------------------

application/controllers/Dashboard.php

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,35 @@ public function index()
8989
//
9090
$this->load->model('cat');
9191
$this->load->model('vucc');
92+
93+
// Load cache driver for dashboard statistics caching (15 minutes)
94+
$this->load->driver('cache', array('adapter' => 'file'));
9295

9396
$data['radio_status'] = $this->cat->recent_status();
9497

95-
// Store info - Use consolidated query for QSO statistics
96-
$qso_stats = $this->logbook_model->get_qso_statistics_consolidated($logbooks_locations_array);
98+
// Create cache key based on user and active logbook
99+
$cache_key = 'dashboard_stats_' . $this->session->userdata('user_id') . '_' . $this->session->userdata('active_station_logbook');
100+
$cache_ttl = 900; // 15 minutes
101+
102+
// Try to get QSO statistics from cache
103+
$qso_stats = $this->cache->get($cache_key . '_qso');
104+
if (!$qso_stats) {
105+
// Cache miss - query database
106+
$qso_stats = $this->logbook_model->get_qso_statistics_consolidated($logbooks_locations_array);
107+
$this->cache->save($cache_key . '_qso', $qso_stats, $cache_ttl);
108+
}
97109
$data['todays_qsos'] = $qso_stats['todays_qsos'];
98110
$data['total_qsos'] = $qso_stats['total_qsos'];
99111
$data['month_qsos'] = $qso_stats['month_qsos'];
100112
$data['year_qsos'] = $qso_stats['year_qsos'];
101113

102-
// Use consolidated countries statistics instead of separate queries
103-
$countries_stats = $this->logbook_model->get_countries_statistics_consolidated($logbooks_locations_array);
114+
// Try to get countries statistics from cache
115+
$countries_stats = $this->cache->get($cache_key . '_countries');
116+
if (!$countries_stats) {
117+
// Cache miss - query database
118+
$countries_stats = $this->logbook_model->get_countries_statistics_consolidated($logbooks_locations_array);
119+
$this->cache->save($cache_key . '_countries', $countries_stats, $cache_ttl);
120+
}
104121

105122
$data['total_countries'] = $countries_stats['Countries_Worked'];
106123
$data['total_countries_confirmed_paper'] = $countries_stats['Countries_Worked_QSL'];
@@ -131,12 +148,27 @@ public function index()
131148

132149
// Only load VUCC data if the card is actually enabled
133150
if ($data['dashboard_vuccgrids_card']) {
134-
$data['vucc'] = $this->vucc->fetchVuccSummary();
135-
$data['vuccSAT'] = $this->vucc->fetchVuccSummary('SAT');
151+
// Try to get VUCC data from cache
152+
$vucc_data = $this->cache->get($cache_key . '_vucc');
153+
if (!$vucc_data) {
154+
// Cache miss - query database
155+
$vucc_data = array(
156+
'vucc' => $this->vucc->fetchVuccSummary(),
157+
'vuccSAT' => $this->vucc->fetchVuccSummary('SAT')
158+
);
159+
$this->cache->save($cache_key . '_vucc', $vucc_data, $cache_ttl);
160+
}
161+
$data['vucc'] = $vucc_data['vucc'];
162+
$data['vuccSAT'] = $vucc_data['vuccSAT'];
136163
}
137164

138-
139-
$QSLStatsBreakdownArray = $this->logbook_model->get_QSLStats($logbooks_locations_array);
165+
// Try to get QSL statistics from cache
166+
$QSLStatsBreakdownArray = $this->cache->get($cache_key . '_qsl');
167+
if (!$QSLStatsBreakdownArray) {
168+
// Cache miss - query database
169+
$QSLStatsBreakdownArray = $this->logbook_model->get_QSLStats($logbooks_locations_array);
170+
$this->cache->save($cache_key . '_qsl', $QSLStatsBreakdownArray, $cache_ttl);
171+
}
140172

141173
$data['total_qsl_sent'] = $QSLStatsBreakdownArray['QSL_Sent'];
142174
$data['total_qsl_rcvd'] = $QSLStatsBreakdownArray['QSL_Received'];

application/controllers/Eqsl.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ public function export()
162162
}
163163

164164
$rows = '';
165+
$successful_uploads = array(); // Collect successful QSO primary keys for batch update
166+
165167
// Grab the list of QSOs to send information about
166168
// perform an HTTP get on each one, and grab the status back
167169
$qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent();
@@ -172,7 +174,7 @@ public function export()
172174
// The station callsign is handled in the ADIF data via eqslqthnickname
173175
$adif = $this->generateAdif($qsl, $data);
174176

175-
$status = $this->uploadQso($adif, $qsl);
177+
$status = $this->uploadQso($adif, $qsl, $successful_uploads);
176178

177179
$timestamp = strtotime($qsl['COL_TIME_ON']);
178180
$rows .= "<td>" . date($custom_date_format, $timestamp) . "</td>";
@@ -188,6 +190,13 @@ public function export()
188190
$rows .= "<td>" . $status . "</td>";
189191
}
190192
$rows .= "</tr>";
193+
194+
// Batch update all successful uploads at the end for better performance
195+
if (!empty($successful_uploads)) {
196+
$affected_rows = $this->eqslmethods_model->eqsl_mark_sent_batch($successful_uploads);
197+
log_message('info', 'eQSL export: Marked ' . $affected_rows . ' QSOs as sent to eQSL');
198+
}
199+
191200
$data['eqsl_table'] = $this->generateResultTable($custom_date_format, $rows);
192201
} else {
193202
$qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent();
@@ -201,7 +210,7 @@ public function export()
201210
$this->load->view('interface_assets/footer');
202211
}
203212

204-
function uploadQso($adif, $qsl)
213+
function uploadQso($adif, $qsl, &$successful_uploads = null)
205214
{
206215
$this->load->model('eqslmethods_model');
207216
$status = "";
@@ -232,7 +241,14 @@ function uploadQso($adif, $qsl)
232241
if ($chi['http_code'] == "200") {
233242
if (stristr($result, "Result: 1 out of 1 records added")) {
234243
$status = "Sent";
235-
$this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
244+
245+
// If batch array is provided, add to it instead of immediate update
246+
if ($successful_uploads !== null) {
247+
$successful_uploads[] = $qsl['COL_PRIMARY_KEY'];
248+
} else {
249+
// Legacy: immediate update (for backward compatibility)
250+
$this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
251+
}
236252
} else {
237253
if (stristr($result, "Error: No match on eQSL_User/eQSL_Pswd")) {
238254
$this->session->set_flashdata('warning', 'Your eQSL username and/or password is incorrect.');
@@ -246,7 +262,11 @@ function uploadQso($adif, $qsl)
246262
$status = "Duplicate";
247263

248264
# Mark the QSL as sent if this is a dupe.
249-
$this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
265+
if ($successful_uploads !== null) {
266+
$successful_uploads[] = $qsl['COL_PRIMARY_KEY'];
267+
} else {
268+
$this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
269+
}
250270
}
251271
}
252272
}

application/controllers/Hrdlog.php

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,26 @@ function setOptions() {
4848
/*
4949
* Function gets all QSOs from given station_id, that are not previously uploaded to hrdlog.
5050
* Adif is build for each qso, and then uploaded, one at a time
51+
* Uses batch fetching to prevent memory exhaustion with large datasets
5152
*/
5253
function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) {
5354
$i = 0;
54-
$data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id);
5555
$errormessages = array();
56+
$batch_size = 1000;
57+
$offset = 0;
58+
$has_more_qsos = true;
5659

5760
$this->load->library('AdifHelper');
5861

59-
if ($data['qsos']) {
62+
// Process QSOs in batches to prevent memory exhaustion
63+
while ($has_more_qsos) {
64+
$data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id, $batch_size, $offset);
65+
66+
if (!$data['qsos'] || $data['qsos']->num_rows() == 0) {
67+
$has_more_qsos = false;
68+
break;
69+
}
70+
6071
foreach ($data['qsos']->result() as $qso) {
6172
$adif = $this->adifhelper->getAdifLine($qso);
6273

@@ -76,26 +87,34 @@ function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) {
7687
log_message('error', 'hrdlog upload stopped for Station_ID: ' . $station_id);
7788
$errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
7889
$result['status'] = 'Error';
79-
break; /* If key is invalid, immediate stop syncing for more QSOs of this station */
90+
break 2; /* If key is invalid, immediate stop syncing for more QSOs of this station */
8091
} else {
8192
log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON);
8293
log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']);
8394
$result['status'] = 'Error';
8495
$errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
8596
}
8697
}
87-
if ($i == 0) {
88-
$result['status']='Error';
98+
99+
// Check if we got a full batch - if not, we've reached the end
100+
if ($data['qsos']->num_rows() < $batch_size) {
101+
$has_more_qsos = false;
102+
} else {
103+
$offset += $batch_size;
104+
log_message('info', 'HRDLog batch upload: Processed ' . $offset . ' QSOs so far for station_id: ' . $station_id);
89105
}
90-
$result['count'] = $i;
91-
$result['errormessages'] = $errormessages;
92-
return $result;
93-
} else {
94-
$result['status'] = 'Error';
95-
$result['count'] = $i;
96-
$result['errormessages'] = $errormessages;
97-
return $result;
98-
}
106+
}
107+
108+
if ($i > 0) {
109+
log_message('info', 'HRDLog upload completed: Total of ' . $i . ' QSOs successfully uploaded for station_id: ' . $station_id);
110+
}
111+
112+
if ($i == 0) {
113+
$result['status']='Error';
114+
}
115+
$result['count'] = $i;
116+
$result['errormessages'] = $errormessages;
117+
return $result;
99118
}
100119

101120
/*

0 commit comments

Comments
 (0)