From bbaec077fccc641e6065f4d94549580702195ac1 Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 19 Jan 2026 14:57:05 +0100 Subject: [PATCH] Do a 2nd lookup for TLE in case SAT is not found with name --- application/controllers/Satellite.php | 6 +++--- application/models/Satellite_model.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/application/controllers/Satellite.php b/application/controllers/Satellite.php index 0d4a0e3fe..83afff861 100644 --- a/application/controllers/Satellite.php +++ b/application/controllers/Satellite.php @@ -384,12 +384,12 @@ class Satellite extends CI_Controller { foreach ($satellites as $sat) { // Loop through known SATs if ( (count($input_sat) > 0) && !((count($input_sat) == 1) && (($input_sat[0] ?? '') == '')) ) { // User wants specific SATs (which isn't "All" or empty)?? if (in_array($sat->satname,$input_sat) || in_array($sat->displayname,$input_sat)) { - $tles[]=$this->satellite_model->get_tle($sat->satname); + $tles[]=$this->satellite_model->get_tle($sat->satname ? $sat->satname : $sat->displayname); } else { continue; } } else { // No specific SAT, but all - $tles[]=$this->satellite_model->get_tle($sat->satname); + $tles[]=$this->satellite_model->get_tle($sat->satname ? $sat->satname : $sat->displayname); } } return $tles; @@ -660,7 +660,7 @@ class Satellite extends CI_Controller { $this->load->model('satellite_model'); $data['satinfo'] = $this->satellite_model->getsatellite($id)->result(); - $data['tleinfo'] = $this->satellite_model->get_tle($data['satinfo'][0]->name); + $data['tleinfo'] = $this->satellite_model->get_tle($data['satinfo'][0]->name ? $data['satinfo'][0]->name : $data['satinfo'][0]->displayname); $this->load->view('satellite/tleinfo', $data); } diff --git a/application/models/Satellite_model.php b/application/models/Satellite_model.php index b95f4e0c8..8a2f18718 100644 --- a/application/models/Satellite_model.php +++ b/application/models/Satellite_model.php @@ -199,7 +199,17 @@ class Satellite_model extends CI_Model { $this->db->where('name', $sat); $this->db->or_where('displayname', $sat); $query = $this->db->get('satellite'); - return $query->row(); + if ($query->num_rows() == 1) { + return $query->row(); + } else { + // Looks for TLEs with displayname in case name fails + $this->db->select('satellite.name AS satellite, satellite.displayname AS displayname, tle.tle, tle.updated'); + $this->db->join('tle', 'satellite.id = tle.satelliteid'); + $this->db->where('displayname', $sat); + $query = $this->db->get('satellite'); + return $query->row(); + } + return null; } }