Sending queue refactoring WIP [MAILPOET-903]

This commit is contained in:
stoletniy
2017-12-21 23:50:43 +03:00
parent bf8b0c81df
commit c0c57f6b67
17 changed files with 684 additions and 171 deletions

View File

@ -7,10 +7,32 @@ class ScheduledTask extends Model {
public static $_table = MP_SCHEDULED_TASKS_TABLE;
const STATUS_COMPLETED = 'completed';
const STATUS_SCHEDULED = 'scheduled';
const STATUS_PAUSED = 'paused';
const PRIORITY_HIGH = 1;
const PRIORITY_MEDIUM = 5;
const PRIORITY_LOW = 10;
function subscribers() {
return $this->hasManyThrough(
__NAMESPACE__.'\Subscriber',
__NAMESPACE__.'\ScheduledTaskSubscriber',
'task_id',
'subscriber_id'
);
}
function pause() {
$this->set('status', self::STATUS_PAUSED);
$this->save();
return ($this->getErrors() === false && $this->id() > 0);
}
function resume() {
$this->setExpr('status', 'NULL');
$this->save();
return ($this->getErrors() === false && $this->id() > 0);
}
function complete() {
$this->processed_at = current_time('mysql');
$this->set('status', self::STATUS_COMPLETED);