[Days with QSOs] Fix if no QSOs found

这个提交包含在:
Andreas 2021-11-14 17:49:35 +01:00
父节点 6e6fe817fe
当前提交 341e8f4a33
共有 2 个文件被更改,包括 136 次插入115 次删除

查看文件

@ -9,6 +9,10 @@ class Dayswithqso_model extends CI_Model
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "select year(COL_TIME_ON) Year, COUNT(DISTINCT TO_DAYS(COL_TIME_ON)) as Days from "
@ -25,6 +29,8 @@ class Dayswithqso_model extends CI_Model
*/
function getCurrentStreak() {
$dates = $this->getDates();
if ($dates) {
$dates = array_reverse($dates);
$streak = 1;
$firstrun = true;
@ -56,12 +62,15 @@ class Dayswithqso_model extends CI_Model
return null;
}
}
}
/*
* Function returns streak that ended yesterday, but can be continued if a qso is made today
*/
function getAlmostCurrentStreak() {
$dates = $this->getDates();
if ($dates) {
$dates = array_reverse($dates);
$streak = 1;
$firstrun = true;
@ -94,6 +103,8 @@ class Dayswithqso_model extends CI_Model
}
}
}
/*
* Function returns the 10 longest streaks of QSOs based on all QSO dates in the log on active station profile
*/
@ -103,6 +114,7 @@ class Dayswithqso_model extends CI_Model
$dateprev = date_create('1900-01-01'); // init variable with an old date
$i = 0;
if ($dates) {
foreach($dates as $date) { // Loop through the result set
$datecurr = date_create($date->date);
if ($dateprev == date_create('1900-01-01')) { // If first run
@ -126,6 +138,8 @@ class Dayswithqso_model extends CI_Model
}
}
if (isset($streaks) && is_array($streaks)) {
usort($streaks, array($this,'compareStreak')); // Sort array, highest streak first
$streaks_trimmed = array_slice($streaks, 0,10); // We only want top 10, so we trim the array
@ -134,6 +148,7 @@ class Dayswithqso_model extends CI_Model
return null;
}
}
}
/*
* Used for sorting the array highest streak first
@ -150,6 +165,10 @@ class Dayswithqso_model extends CI_Model
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "select distinct cast(col_time_on as date) as date from "

查看文件

@ -1,6 +1,7 @@
$.ajax({
url: base_url + 'index.php/dayswithqso/get_days',
success: function (data) {
if ($.trim(data)) {
var labels = [];
var dataDxcc = [];
$.each(data, function () {
@ -43,4 +44,5 @@ $.ajax({
}
});
}
}
});