Rename unprocessed status, refactor counting a bit more clearly [MAILPOET-987]
This commit is contained in:
@ -4,7 +4,7 @@ namespace MailPoet\Models;
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class ScheduledTaskSubscriber extends Model {
|
||||
const STATUS_TO_PROCESS = 0;
|
||||
const STATUS_UNPROCESSED = 0;
|
||||
const STATUS_PROCESSED = 1;
|
||||
|
||||
public static $_table = MP_SCHEDULED_TASK_SUBSCRIBERS_TABLE;
|
||||
@ -21,7 +21,7 @@ class ScheduledTaskSubscriber extends Model {
|
||||
|
||||
$task_subscriber->task_id = $data['task_id'];
|
||||
$task_subscriber->subscriber_id = $data['subscriber_id'];
|
||||
$task_subscriber->processed = !empty($data['processed']) ? self::STATUS_PROCESSED : self::STATUS_TO_PROCESS;
|
||||
$task_subscriber->processed = !empty($data['processed']) ? self::STATUS_PROCESSED : self::STATUS_UNPROCESSED;
|
||||
$task_subscriber->save();
|
||||
|
||||
return $task_subscriber;
|
||||
@ -36,12 +36,12 @@ class ScheduledTaskSubscriber extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
static function getToProcessCount($task_id) {
|
||||
return self::getCount($task_id, false);
|
||||
static function getUnprocessedCount($task_id) {
|
||||
return self::getCount($task_id, self::STATUS_UNPROCESSED);
|
||||
}
|
||||
|
||||
static function getProcessedCount($task_id) {
|
||||
return self::getCount($task_id, true);
|
||||
return self::getCount($task_id, self::STATUS_PROCESSED);
|
||||
}
|
||||
|
||||
static function getTotalCount($task_id) {
|
||||
@ -51,10 +51,7 @@ class ScheduledTaskSubscriber extends Model {
|
||||
private static function getCount($task_id, $processed = null) {
|
||||
$orm = self::where('task_id', $task_id);
|
||||
if(!is_null($processed)) {
|
||||
$orm->where(
|
||||
'processed',
|
||||
($processed) ? self::STATUS_PROCESSED : self::STATUS_TO_PROCESS
|
||||
);
|
||||
$orm->where('processed', $processed);
|
||||
}
|
||||
return $orm->count();
|
||||
}
|
||||
|
Reference in New Issue
Block a user