Skip to content
Snippets Groups Projects
Commit 97646994 authored by Dominik František Bučík's avatar Dominik František Bučík
Browse files

chore: merge branch 'cron_disable' into 'main'

feat: :guitar: Cron enable/disalbe flag

See merge request perun-proxy-aai/simplesamlphp/simplesamlphp-module-proxystatistics!92
parents f10c5886 0df119c2
No related branches found
No related tags found
1 merge request!92feat: 🎸 Cron enable/disalbe flag
Pipeline #369317 passed
......@@ -104,9 +104,17 @@ $config = [
*/
//'apiWritePasswordHash' => password_hash('ap1Wr1T3rP@S$'),
'ignoredIds' => [
'IDP' => ['spentityid1', 'spentityid2', 'spentityid3',],
'SP' => ['idpentityid1', 'idpentityid2', 'idpentityid3',],
],
/*
* List of IDP and/or SP EntityIDs for which the login statistic will be ignored even
* when requested to be instered into the storage. By default lists are empty
*/
//'ignoredIds' => [
// 'IDP' => ['spentityid1', 'spentityid2', 'spentityid3',],
// 'SP' => ['idpentityid1', 'idpentityid2', 'idpentityid3',],
//],
/*
* Enabled or disables CRON hook (aggregating the stats). By default is enabled.
*/
//'cronEnabled' => false,
];
......@@ -3,6 +3,7 @@
declare(strict_types=1);
use SimpleSAML\Logger;
use SimpleSAML\Module\proxystatistics\Config;
use SimpleSAML\Module\proxystatistics\DatabaseCommand;
/**
......@@ -18,8 +19,13 @@ function proxystatistics_hook_cron(&$croninfo)
return;
}
Logger::info('cron [proxystatistics]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
$config = Config::getInstance();
if (!$config->isCronEnabled()) {
Logger::debug('cron [proxystatistics]: Skipping cron - disabled by configuration');
return;
}
Logger::info('cron [proxystatistics]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
try {
$dbCmd = new DatabaseCommand();
$dbCmd->aggregate();
......
......@@ -43,6 +43,8 @@ class Config
private const IGNORED_IDS = 'ignoredIds';
private const CRON_ENABLED = 'cronEnabled';
private $config;
private $store;
......@@ -67,6 +69,8 @@ class Config
private $ignoredIds;
private $cronEnabled;
private static $instance;
private function __construct()
......@@ -79,6 +83,7 @@ class Config
$this->keepPerUser = $this->config->getIntegerRange(self::KEEP_PER_USER, 31, 1827, 31);
$this->requiredAuthSource = $this->config->getString(self::REQUIRE_AUTH_SOURCE, '');
$this->idAttribute = $this->config->getString(self::USER_ID_ATTRIBUTE, 'uid');
$this->cronEnabled = $this->config->getBoolean(self::CRON_ENABLED, true);
$this->apiWriteEnabled = $this->config->getBoolean(self::API_WRITE_ENABLED, false);
$this->ignoredIds = $this->config->getArray(self::IGNORED_IDS, []);
if ($this->apiWriteEnabled) {
......@@ -172,4 +177,9 @@ class Config
{
return $this->ignoredIds;
}
public function isCronEnabled()
{
return $this->cronEnabled;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment