diff --git a/application/controllers/Debug.php b/application/controllers/Debug.php
index 2e06ccf87..8857c7b4d 100644
--- a/application/controllers/Debug.php
+++ b/application/controllers/Debug.php
@@ -21,6 +21,7 @@ class Debug extends CI_Controller
$this->load->model('Logbook_model');
$this->load->model('Debug_model');
$this->load->model('Stations');
+ $this->load->model('cron_model');
$footerData = [];
$footerData['scripts'] = ['assets/js/sections/debug.js'];
@@ -62,6 +63,14 @@ class Debug extends CI_Controller
$data['userdata_status'] = $userdata_status;
}
+ $data['dxcc_update'] = $this->cron_model->cron('update_dxcc')->row();
+ $data['dok_update'] = $this->cron_model->cron('update_update_dok')->row();
+ $data['lotw_user_update'] = $this->cron_model->cron('update_lotw_users')->row();
+ $data['pota_update'] = $this->cron_model->cron('update_update_pota')->row();
+ $data['scp_update'] = $this->cron_model->cron('update_update_clublog_scp')->row();
+ $data['sota_update'] = $this->cron_model->cron('update_update_sota')->row();
+ $data['wwff_update'] = $this->cron_model->cron('update_update_wwff')->row();
+
$data['page_title'] = "Debug";
$this->load->view('interface_assets/header', $data);
diff --git a/application/controllers/Update.php b/application/controllers/Update.php
index e6189c9ff..9921ce059 100644
--- a/application/controllers/Update.php
+++ b/application/controllers/Update.php
@@ -179,6 +179,10 @@ class Update extends CI_Controller {
// Updates the DXCC & Exceptions from the Club Log Cty.xml file.
public function dxcc() {
+
+ $this->load->model('cron_model');
+ $this->cron_model->set_last_run($this->router->class.'_'.$this->router->method);
+
$this->update_status("Downloading file");
// give it 10 minutes...
@@ -239,9 +243,6 @@ class Update extends CI_Controller {
$html .= "Dxcc Prefixes: ".$this->db->count_all('dxcc_prefixes')."
";
} else {
$html = $done."....
";
- $datetime = new DateTime("now", new DateTimeZone('UTC'));
- $datetime = $datetime->format('Ymd h:i');
- $this->optionslib->update('dxcc_clublog_update', $datetime , 'no');
}
file_put_contents($this->make_update_path("status.html"), $html);
@@ -327,9 +328,6 @@ class Update extends CI_Controller {
if ($nCount > 0)
{
echo "DONE: " . number_format($nCount) . " callsigns loaded";
- $datetime = new DateTime("now", new DateTimeZone('UTC'));
- $datetime = $datetime->format('Ymd h:i');
- $this->optionslib->update('scp_update', $datetime , 'no');
} else {
echo "FAILED: Empty file";
}
@@ -401,9 +399,6 @@ class Update extends CI_Controller {
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds
";
echo "Records inserted: " . $i . "
";
- $datetime = new DateTime("now", new DateTimeZone('UTC'));
- $datetime = $datetime->format('Ymd h:i');
- $this->optionslib->update('lotw_users_update', $datetime , 'no');
}
public function lotw_check() {
@@ -439,9 +434,6 @@ class Update extends CI_Controller {
if ($nCount > 0)
{
echo "DONE: " . number_format($nCount) . " DOKs and SDOKs saved";
- $datetime = new DateTime("now", new DateTimeZone('UTC'));
- $datetime = $datetime->format('Ymd h:i');
- $this->optionslib->update('dok_file_update', $datetime , 'no');
} else {
echo"FAILED: Empty file";
}
@@ -493,9 +485,6 @@ class Update extends CI_Controller {
if ($nCount > 0)
{
echo "DONE: " . number_format($nCount) . " SOTA's saved";
- $datetime = new DateTime("now", new DateTimeZone('UTC'));
- $datetime = $datetime->format('Ymd h:i');
- $this->optionslib->update('sota_file_update', $datetime , 'no');
} else {
echo"FAILED: Empty file";
}
@@ -547,9 +536,6 @@ class Update extends CI_Controller {
if ($nCount > 0)
{
echo "DONE: " . number_format($nCount) . " WWFF's saved";
- $datetime = new DateTime("now", new DateTimeZone('UTC'));
- $datetime = $datetime->format('Ymd h:i');
- $this->optionslib->update('wwff_file_update', $datetime , 'no');
} else {
echo"FAILED: Empty file";
}
@@ -597,9 +583,6 @@ class Update extends CI_Controller {
if ($nCount > 0)
{
echo "DONE: " . number_format($nCount) . " POTA's saved";
- $datetime = new DateTime("now", new DateTimeZone('UTC'));
- $datetime = $datetime->format('Ymd h:i');
- $this->optionslib->update('pota_file_update', $datetime , 'no');
} else {
echo"FAILED: Empty file";
}
diff --git a/application/migrations/196_cron_table.php b/application/migrations/196_cron_table.php
index 17fb5eaeb..a9f2aa7e3 100644
--- a/application/migrations/196_cron_table.php
+++ b/application/migrations/196_cron_table.php
@@ -1,13 +1,13 @@
db->table_exists('cron')) {
+ // define the structure of the new cron table
$this->dbforge->add_field(array(
'id' => array(
'type' => 'VARCHAR',
@@ -52,32 +52,165 @@ class Migration_cron_table extends CI_Migration {
'null' => TRUE,
),
));
-
+
+ // we set the key for the id, in this case the id is not numerical
$this->dbforge->add_key('id', TRUE);
+ // now we can create the new table
$this->dbforge->create_table('cron');
+ // to transfer data for the file updates we load the optionslib library
+ $this->load->library('OptionsLib');
+
+ // and we fill the table with the cronjobs
$data = array(
- array('id' => 'clublog_upload', 'enabled' => '0', 'status' => 'healthy', 'description' => 'Upload QSOs to Clublog', 'function' => 'index.php/clublog/upload', 'expression' => '3 */6 * * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'lotw_lotw_upload', 'enabled' => '0', 'status' => 'healthy', 'description' => 'Upload QSOs to LoTW', 'function' => 'index.php/lotw/lotw_upload', 'expression' => '0 */1 * * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'qrz_upload', 'enabled' => '0', 'status' => 'healthy', 'description' => 'Upload QSOs to QRZ', 'function' => 'index.php/qrz/upload', 'expression' => '6 */6 * * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'qrz_download', 'enabled' => '0', 'status' => 'healthy', 'description' => 'Download QSOs from QRZ', 'function' => 'index.php/qrz/download', 'expression' => '18 */6 * * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'hrdlog_upload', 'enabled' => '0', 'status' => 'healthy', 'description' => 'Upload QSOs to HRD', 'function' => 'index.php/hrdlog/upload', 'expression' => '12 */6 * * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'eqsl_sync', 'enabled' => '0', 'status' => 'healthy', 'description' => 'Upload/download QSOs to/from Eqsl', 'function' => 'index.php/eqsl/sync', 'expression' => '9 */6 * * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'update_lotw_users', 'enabled' => '1', 'status' => 'healthy', 'description' => 'Update LOTW Users Activity', 'function' => 'index.php/update/lotw_users', 'expression' => '10 1 * * 1', 'last_run' => null, 'next_run' => null ),
- array('id' => 'update_update_clublog_scp', 'enabled' => '1', 'status' => 'healthy', 'description' => 'Update Clublog SCP Database File', 'function' => 'index.php/update/update_clublog_scp', 'expression' => '0 0 * * 0', 'last_run' => null, 'next_run' => null ),
- array('id' => 'update_update_dok', 'enabled' => '1', 'status' => 'healthy', 'description' => 'Update DOK File', 'function' => 'index.php/update/update_dok', 'expression' => '0 0 1 * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'update_update_sota', 'enabled' => '1', 'status' => 'healthy', 'description' => 'Update SOTA File', 'function' => 'index.php/update/update_sota', 'expression' => '0 0 1 * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'update_update_wwff', 'enabled' => '1', 'status' => 'healthy', 'description' => 'Update WWFF File', 'function' => 'index.php/update/update_wwff', 'expression' => '0 0 1 * *', 'last_run' => null, 'next_run' => null ),
- array('id' => 'update_update_pota', 'enabled' => '1', 'status' => 'healthy', 'description' => 'Update POTA File', 'function' => 'index.php/update/update_pota', 'expression' => '0 0 1 * *', 'last_run' => null, 'next_run' => null ),
+ array(
+ 'id' => 'clublog_upload',
+ 'enabled' => '0',
+ 'status' => 'pending',
+ 'description' => 'Upload QSOs to Clublog',
+ 'function' => 'index.php/clublog/upload',
+ 'expression' => '3 */6 * * *',
+ 'last_run' => null,
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'lotw_lotw_upload',
+ 'enabled' => '0',
+ 'status' => 'pending',
+ 'description' => 'Upload QSOs to LoTW',
+ 'function' => 'index.php/lotw/lotw_upload',
+ 'expression' => '0 */1 * * *',
+ 'last_run' => null,
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'qrz_upload',
+ 'enabled' => '0',
+ 'status' => 'pending',
+ 'description' => 'Upload QSOs to QRZ',
+ 'function' => 'index.php/qrz/upload',
+ 'expression' => '6 */6 * * *',
+ 'last_run' => null,
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'qrz_download',
+ 'enabled' => '0',
+ 'status' => 'pending',
+ 'description' => 'Download QSOs from QRZ',
+ 'function' => 'index.php/qrz/download',
+ 'expression' => '18 */6 * * *',
+ 'last_run' => null,
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'hrdlog_upload',
+ 'enabled' => '0',
+ 'status' => 'pending',
+ 'description' => 'Upload QSOs to HRD',
+ 'function' => 'index.php/hrdlog/upload',
+ 'expression' => '12 */6 * * *',
+ 'last_run' => null,
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'eqsl_sync',
+ 'enabled' => '0',
+ 'status' => 'pending',
+ 'description' => 'Upload/download QSOs to/from Eqsl',
+ 'function' => 'index.php/eqsl/sync',
+ 'expression' => '9 */6 * * *',
+ 'last_run' => null,
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'update_lotw_users',
+ 'enabled' => '1',
+ 'status' => 'pending',
+ 'description' => 'Update LOTW Users Activity',
+ 'function' => 'index.php/update/lotw_users',
+ 'expression' => '10 1 * * 1',
+ 'last_run' => ($this->optionslib->get_option('lotw_users_update') ? date("Y-m-d H:i", strtotime($this->optionslib->get_option('lotw_users_update'))) : null),
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'update_update_clublog_scp',
+ 'enabled' => '1',
+ 'status' => 'pending',
+ 'description' => 'Update Clublog SCP Database File',
+ 'function' => 'index.php/update/update_clublog_scp',
+ 'expression' => '0 0 * * 0',
+ 'last_run' => ($this->optionslib->get_option('scp_update') ? date("Y-m-d H:i", strtotime($this->optionslib->get_option('scp_update'))) : null),
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'update_update_dok',
+ 'enabled' => '1',
+ 'status' => 'pending',
+ 'description' => 'Update DOK File',
+ 'function' => 'index.php/update/update_dok',
+ 'expression' => '0 0 1 * *',
+ 'last_run' => ($this->optionslib->get_option('dok_file_update') ? date("Y-m-d H:i", strtotime($this->optionslib->get_option('dok_file_update'))) : null),
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'update_update_sota',
+ 'enabled' => '1',
+ 'status' => 'pending',
+ 'description' => 'Update SOTA File',
+ 'function' => 'index.php/update/update_sota',
+ 'expression' => '0 0 1 * *',
+ 'last_run' => ($this->optionslib->get_option('sota_file_update') ? date("Y-m-d H:i", strtotime($this->optionslib->get_option('sota_file_update'))) : null),
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'update_update_wwff',
+ 'enabled' => '1',
+ 'status' => 'pending',
+ 'description' => 'Update WWFF File',
+ 'function' => 'index.php/update/update_wwff',
+ 'expression' => '0 0 1 * *',
+ 'last_run' => ($this->optionslib->get_option('wwff_file_update') ? date("Y-m-d H:i", strtotime($this->optionslib->get_option('wwff_file_update'))) : null),
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'update_update_pota',
+ 'enabled' => '1',
+ 'status' => 'pending',
+ 'description' => 'Update POTA File',
+ 'function' => 'index.php/update/update_pota',
+ 'expression' => '0 0 1 * *',
+ 'last_run' => ($this->optionslib->get_option('pota_file_update') ? date("Y-m-d H:i", strtotime($this->optionslib->get_option('pota_file_update'))) : null),
+ 'next_run' => null
+ ),
+ array(
+ 'id' => 'update_dxcc',
+ 'enabled' => '1',
+ 'status' => 'pending',
+ 'description' => 'Update DXCC data',
+ 'function' => 'index.php/update/dxcc',
+ 'expression' => '0 0 1 */2 *',
+ 'last_run' => ($this->optionslib->get_option('dxcc_clublog_update') ? date("Y-m-d H:i", strtotime($this->optionslib->get_option('dxcc_clublog_update'))) : null),
+ 'next_run' => null
+ ),
);
-
$this->db->insert_batch('cron', $data);
+
+ // since we transfered the source for the file update timestamps we don't need this options anymore
+ $this->db->delete('options', array('option_name' => 'lotw_users_update'));
+ $this->db->delete('options', array('option_name' => 'scp_update'));
+ $this->db->delete('options', array('option_name' => 'dok_file_update'));
+ $this->db->delete('options', array('option_name' => 'sota_file_update'));
+ $this->db->delete('options', array('option_name' => 'wwff_file_update'));
+ $this->db->delete('options', array('option_name' => 'pota_file_update'));
+ $this->db->delete('options', array('option_name' => 'dxcc_clublog_update'));
}
}
- public function down()
- {
+ public function down() {
+
$this->dbforge->drop_table('cron');
+
}
}
diff --git a/application/views/debug/index.php b/application/views/debug/index.php
index 67ef0ef66..75aeae2b5 100644
--- a/application/views/debug/index.php
+++ b/application/views/debug/index.php
@@ -462,38 +462,38 @@