Chunked also for custom_export

This commit is contained in:
int2001
2025-12-05 06:39:44 +00:00
parent 1b2bb022e3
commit bd3d4256e6
2 changed files with 89 additions and 5 deletions

View File

@@ -281,6 +281,51 @@ class adif_data extends CI_Model {
return $this->db->get();
}
function export_custom_chunked($from, $to, $station_id, $exportLotw = false, $onlyop = null, $offset = 0, $limit = 5000) {
// Copy export_custom logic but add chunking for station_id > 0
$this->load->model('Stations');
if ($station_id == 0) {
// Use existing chunked export_all for all stations
return $this->export_all_chunked(null, $from, $to, $exportLotw, $onlyop, $offset, $limit);
}
// Check station access
if (!$this->Stations->check_station_is_accessible($station_id)) {
return;
}
// Build query identical to export_custom but add LIMIT/OFFSET
$this->db->select(''.$this->config->item('table_name').'.*, station_profile.*, dxcc_entities.name as station_country');
$this->db->from($this->config->item('table_name'));
$this->db->where($this->config->item('table_name').'.station_id', $station_id);
// Apply same filters as export_custom
if ($from) {
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) >= ", $from);
}
if ($to) {
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= ",$to);
}
if ($onlyop) {
$this->db->where("upper(".$this->config->item('table_name').".col_operator)",$onlyop);
}
if ($exportLotw) {
$this->db->group_start();
$this->db->where($this->config->item('table_name').".COL_LOTW_QSL_SENT != 'Y'");
$this->db->or_where($this->config->item('table_name').".COL_LOTW_QSL_SENT", NULL);
$this->db->group_end();
}
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer');
// Add chunking
$this->db->limit($limit, $offset);
return $this->db->get();
}
}