Make DXCC entity matching case-insensitive
Updated batchWorkedQuery and related logic to perform case-insensitive matching for DXCC entities using UPPER() in SQL WHERE conditions. This ensures entities are matched regardless of case, improving reliability of lookups.
这个提交包含在:
父节点
9b17ff9250
当前提交
9fb5feffe7
共有 1 个文件被更改,包括 40 次插入 和 5 次删除
|
|
@ -100,19 +100,36 @@ class Workabledxcc_model extends CI_Model
|
||||||
*/
|
*/
|
||||||
private function batchWorkedQuery($entities, $logbooks_locations_array)
|
private function batchWorkedQuery($entities, $logbooks_locations_array)
|
||||||
{
|
{
|
||||||
// Use a single query with GROUP BY to check all entities at once
|
// Create case-insensitive matching for DXCC entities
|
||||||
|
$whereConditions = array();
|
||||||
|
foreach ($entities as $entity) {
|
||||||
|
$whereConditions[] = "UPPER(COL_COUNTRY) = UPPER('" . $this->db->escape_str($entity) . "')";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($whereConditions)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$whereClause = '(' . implode(' OR ', $whereConditions) . ')';
|
||||||
|
|
||||||
$this->db->select('COL_COUNTRY')
|
$this->db->select('COL_COUNTRY')
|
||||||
->distinct()
|
->distinct()
|
||||||
->from($this->config->item('table_name'))
|
->from($this->config->item('table_name'))
|
||||||
->where('COL_PROP_MODE !=', 'SAT')
|
->where('COL_PROP_MODE !=', 'SAT')
|
||||||
->where_in('station_id', $logbooks_locations_array)
|
->where_in('station_id', $logbooks_locations_array)
|
||||||
->where_in('COL_COUNTRY', array_map('urlencode', $entities));
|
->where($whereClause);
|
||||||
|
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
foreach ($query->result() as $row) {
|
foreach ($query->result() as $row) {
|
||||||
$results[urldecode($row->COL_COUNTRY)] = true;
|
// Store with the original entity case for lookup
|
||||||
|
foreach ($entities as $entity) {
|
||||||
|
if (strtoupper($row->COL_COUNTRY) === strtoupper($entity)) {
|
||||||
|
$results[$entity] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
@ -127,19 +144,37 @@ class Workabledxcc_model extends CI_Model
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create case-insensitive matching for DXCC entities
|
||||||
|
$whereConditions = array();
|
||||||
|
foreach ($entities as $entity) {
|
||||||
|
$whereConditions[] = "UPPER(COL_COUNTRY) = UPPER('" . $this->db->escape_str($entity) . "')";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($whereConditions)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$whereClause = '(' . implode(' OR ', $whereConditions) . ')';
|
||||||
|
|
||||||
$this->db->select('COL_COUNTRY')
|
$this->db->select('COL_COUNTRY')
|
||||||
->distinct()
|
->distinct()
|
||||||
->from($this->config->item('table_name'))
|
->from($this->config->item('table_name'))
|
||||||
->where('COL_PROP_MODE !=', 'SAT')
|
->where('COL_PROP_MODE !=', 'SAT')
|
||||||
->where($confirmationCriteria)
|
->where($confirmationCriteria)
|
||||||
->where_in('station_id', $logbooks_locations_array)
|
->where_in('station_id', $logbooks_locations_array)
|
||||||
->where_in('COL_COUNTRY', array_map('urlencode', $entities));
|
->where($whereClause);
|
||||||
|
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
foreach ($query->result() as $row) {
|
foreach ($query->result() as $row) {
|
||||||
$results[urldecode($row->COL_COUNTRY)] = true;
|
// Store with the original entity case for lookup
|
||||||
|
foreach ($entities as $entity) {
|
||||||
|
if (strtoupper($row->COL_COUNTRY) === strtoupper($entity)) {
|
||||||
|
$results[$entity] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用