Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion application/models/Labels_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function export_printrequested($station_id = NULL) {
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->where_in('COL_QSL_SENT', array('R', 'Q'));
$this->db->order_by("COL_DXCC", "ASC");
$this->db->order_by("COL_CALL", "ASC");
$this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC");

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complex CASE statement is duplicated in both functions. Consider extracting this SQL expression into a private method or class constant to improve maintainability and reduce code duplication.

Suggested change
$this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC");
$this->db->order_by($this->_get_case_order_by_expression(), "ASC");

Copilot uses AI. Check for mistakes.
$this->db->order_by("COL_SAT_NAME", "ASC");
$this->db->order_by("COL_SAT_MODE", "ASC");
$this->db->order_by("COL_BAND_RX", "ASC");
Expand All @@ -169,6 +169,7 @@ function export_printrequestedids($ids) {
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->where_in('COL_PRIMARY_KEY', $ids);
$this->db->order_by("COL_DXCC", "ASC");
$this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC");

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is missing the satellite-related order_by clauses that are present in export_printrequested(). Consider whether COL_SAT_NAME, COL_SAT_MODE, and COL_BAND_RX sorting should also be applied here for consistency.

Suggested change
$this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC");
$this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC");
$this->db->order_by("COL_SAT_NAME", "ASC");
$this->db->order_by("COL_SAT_MODE", "ASC");
$this->db->order_by("COL_BAND_RX", "ASC");

Copilot uses AI. Check for mistakes.
$query = $this->db->get($this->config->item('table_name'));

return $query;
Expand Down
Loading