Merge branch 'dev' into contests-update

This commit is contained in:
Florian (DF2ET)
2025-10-23 09:02:45 +02:00
committed by GitHub
100 changed files with 24037 additions and 20100 deletions

View File

@@ -0,0 +1,53 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_randomize extends CI_Migration {
/**
* We randomize the minute for clublog cronjobs to reduce the load on clublog servers
* We only apply this change if the cronjob expression is still set to the default value
*/
public function up() {
/**
* Reference:
* - clublog_upload was added in mig 196
* - clublog_download was added in mig 197
*/
$cron_jobs = [
'clublog_download' => '7 00 * * *',
'clublog_upload' => '3 */6 * * *',
];
foreach ($cron_jobs as $id => $default_expression) {
$query = $this->db->query("SELECT expression FROM cron WHERE id=?", [$id]);
$row = $query->row();
if ($row && $row->expression === $default_expression) {
$random_minute = mt_rand(0, 59);
$parts = explode(' ', $default_expression);
$parts[0] = (string)$random_minute;
$new_expression = implode(' ', $parts);
// all expressions should have the same format
$new_expression = str_replace(' 00 ', ' 0 ', $new_expression);
$this->dbtry("UPDATE cron SET expression='" . $new_expression . "' WHERE id='" . $id . "'");
}
}
}
public function down() {
// no way back necessary
}
function dbtry($what) {
try {
$this->db->query($what);
} catch (Exception $e) {
log_message("error", "Something gone wrong while altering a table: ".$e." // Executing: ".$this->db->last_query());
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
Tag Wavelog as Version 2.1.2
*/
class Migration_tag_2_1_2 extends CI_Migration {
public function up()
{
// Tag Wavelog New Version
$this->db->where('option_name', 'version');
$this->db->update('options', array('option_value' => '2.1.2'));
// Trigger Version Info Dialog
$this->db->where('option_type', 'version_dialog');
$this->db->where('option_name', 'confirmed');
$this->db->update('user_options', array('option_value' => 'false'));
// Also set Version Dialog to "both" if only custom text is applied
$this->db->where('option_name', 'version_dialog');
$this->db->where('option_value', 'custom_text');
$this->db->update('options', array('option_value' => 'both'));
}
public function down()
{
$this->db->where('option_name', 'version');
$this->db->update('options', array('option_value' => '2.1.1'));
}
}

View File

@@ -0,0 +1,64 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
Create table vuccgrids for use in Gridmap country filtering
*/
class Migration_add_grid_country extends CI_Migration {
public function up()
{
$sql = "CREATE TABLE IF NOT EXISTS vuccgrids (
id INT AUTO_INCREMENT PRIMARY KEY,
adif INT NOT NULL,
gridsquare VARCHAR(8) NOT NULL,
creation_date TIMESTAMP NOT NULL default CURRENT_TIMESTAMP,
last_modified TIMESTAMP NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uq_adif_grid (adif, gridsquare)
);";
$this->dbtry($sql);
if ($this->chk4cron('vucc_grid_file') == 0) {
$data = array(
array(
'id' => 'vucc_grid_file',
'enabled' => '0',
'status' => 'enabled',
'description' => 'Update TQSL VUCC Grids file',
'function' => 'index.php/update/update_vucc_grids',
'expression' => '0 0 1 * *',
'last_run' => null,
'next_run' => null
));
$this->db->insert_batch('cron', $data);
}
}
public function down()
{
$sql = "DROP TABLE IF EXISTS vuccgrids;";
$this->dbtry($sql);
if ($this->chk4cron('vucc_grid_file') > 0) {
$this->db->query("delete from cron where id='vucc_grid_file'");
}
}
function dbtry($what) {
try {
$this->db->query($what);
} catch (Exception $e) {
log_message("error", "Something gone wrong while altering a table: ".$e." // Executing: ".$this->db->last_query());
}
}
function chk4cron($cronkey) {
$query = $this->db->query("select count(id) as cid from cron where id=?",$cronkey);
$row = $query->row();
return $row->cid ?? 0;
}
}