Hopefuly fixes #147; made tag sub delay configurable
This commit is contained in:
parent
6e77aa849f
commit
48b182b2f6
@ -43,8 +43,15 @@ class JobTask extends Rails\ActiveRecord\Base
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "calculate_tag_subscriptions":
|
case "calculate_tag_subscriptions":
|
||||||
return "last run: " . (isset($this->data->last_run) ? $this->data->last_run : 'never');
|
if (CONFIG()->tag_subscription_delay && isset($this->data->last_run)) {
|
||||||
break;
|
$nextRun = date('Y-m-d H:i:s', strtotime('+' . CONFIG()->tag_subscription_delay, strtotime($this->data->last_run)));
|
||||||
|
} else {
|
||||||
|
$nextRun = 'imminent';
|
||||||
|
}
|
||||||
|
|
||||||
|
$lastRun = (isset($this->data->last_run) ? $this->data->last_run : 'never');
|
||||||
|
|
||||||
|
return "last run: " . $lastRun . '; next run: ' . $nextRun;
|
||||||
|
|
||||||
// case "upload_posts_to_mirrors"
|
// case "upload_posts_to_mirrors"
|
||||||
// ret = ""
|
// ret = ""
|
||||||
@ -264,12 +271,17 @@ class JobTask extends Rails\ActiveRecord\Base
|
|||||||
|
|
||||||
public function execute_calculate_tag_subscriptions()
|
public function execute_calculate_tag_subscriptions()
|
||||||
{
|
{
|
||||||
|
if (CONFIG()->tag_subscription_delay) {
|
||||||
if (Rails::cache()->read("delay-tag-sub-calc")) {
|
if (Rails::cache()->read("delay-tag-sub-calc")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Rails::cache()->write("delay-tag-sub-calc", ['expires_in' => '360 minutes']);
|
|
||||||
|
Rails::cache()->write("delay-tag-sub-calc", 1, ['expires_in' => CONFIG()->tag_subscription_delay]);
|
||||||
|
}
|
||||||
|
|
||||||
TagSubscription::process_all();
|
TagSubscription::process_all();
|
||||||
$this->updateAttributes(['data' => ['last_run' => date('Y-m-d H:i')]]);
|
|
||||||
|
$this->updateAttributes(['data' => ['last_run' => date('Y-m-d H:i:s')]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
|
@ -462,6 +462,14 @@ abstract class DefaultConfig
|
|||||||
# Set to 0 to wait indefinitely.
|
# Set to 0 to wait indefinitely.
|
||||||
public $http_streaming_timeout = 10;
|
public $http_streaming_timeout = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't process tag subscriptions again within this time.
|
||||||
|
* Set to null to process tag subscriptions asap.
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
public $tag_subscription_delay = '360 minutes';
|
||||||
|
|
||||||
public function __get($prop)
|
public function __get($prop)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user