Remove model OverdueNotification
This commit is contained in:
parent
abe9371f32
commit
a7c157df3c
|
|
@ -14,11 +14,9 @@ use Symfony\Component\Console\Command\Command;
|
|||
* @property \Kanboard\Model\Notification $notification
|
||||
* @property \Kanboard\Model\Project $project
|
||||
* @property \Kanboard\Model\ProjectPermission $projectPermission
|
||||
* @property \Kanboard\Model\ProjectAnalytic $projectAnalytic
|
||||
* @property \Kanboard\Model\ProjectDailyColumnStats $projectDailyColumnStats
|
||||
* @property \Kanboard\Model\ProjectDailyStats $projectDailyStats
|
||||
* @property \Kanboard\Model\SubtaskExport $subtaskExport
|
||||
* @property \Kanboard\Model\OverdueNotification $overdueNotification
|
||||
* @property \Kanboard\Model\Task $task
|
||||
* @property \Kanboard\Model\TaskExport $taskExport
|
||||
* @property \Kanboard\Model\TaskFinder $taskFinder
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Kanboard\Console;
|
||||
|
||||
use Kanboard\Model\Task;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
|
@ -19,7 +20,7 @@ class TaskOverdueNotification extends Base
|
|||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$tasks = $this->overdueNotification->sendOverdueTaskNotifications();
|
||||
$tasks = $this->sendOverdueTaskNotifications();
|
||||
|
||||
if ($input->getOption('show')) {
|
||||
$this->showTable($output, $tasks);
|
||||
|
|
@ -47,4 +48,69 @@ class TaskOverdueNotification extends Base
|
|||
->setRows($rows)
|
||||
->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send overdue tasks
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function sendOverdueTaskNotifications()
|
||||
{
|
||||
$tasks = $this->taskFinder->getOverdueTasks();
|
||||
|
||||
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
|
||||
$users = $this->userNotification->getUsersWithNotificationEnabled($project_id);
|
||||
|
||||
foreach ($users as $user) {
|
||||
$this->sendUserOverdueTaskNotifications($user, $project_tasks);
|
||||
}
|
||||
}
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send overdue tasks for a given user
|
||||
*
|
||||
* @access public
|
||||
* @param array $user
|
||||
* @param array $tasks
|
||||
*/
|
||||
public function sendUserOverdueTaskNotifications(array $user, array $tasks)
|
||||
{
|
||||
$user_tasks = array();
|
||||
|
||||
foreach ($tasks as $task) {
|
||||
if ($this->userNotificationFilter->shouldReceiveNotification($user, array('task' => $task))) {
|
||||
$user_tasks[] = $task;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($user_tasks)) {
|
||||
$this->userNotification->sendUserNotification(
|
||||
$user,
|
||||
Task::EVENT_OVERDUE,
|
||||
array('tasks' => $user_tasks, 'project_name' => $tasks[0]['project_name'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Group a collection of records by a column
|
||||
*
|
||||
* @access public
|
||||
* @param array $collection
|
||||
* @param string $column
|
||||
* @return array
|
||||
*/
|
||||
public function groupByColumn(array $collection, $column)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($collection as $item) {
|
||||
$result[$item[$column]][] = $item;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,9 @@ use Pimple\Container;
|
|||
* @property \Kanboard\Model\LastLogin $lastLogin
|
||||
* @property \Kanboard\Model\Link $link
|
||||
* @property \Kanboard\Model\Notification $notification
|
||||
* @property \Kanboard\Model\OverdueNotification $overdueNotification
|
||||
* @property \Kanboard\Model\PasswordReset $passwordReset
|
||||
* @property \Kanboard\Model\Project $project
|
||||
* @property \Kanboard\Model\ProjectActivity $projectActivity
|
||||
* @property \Kanboard\Model\ProjectAnalytic $projectAnalytic
|
||||
* @property \Kanboard\Model\ProjectDuplication $projectDuplication
|
||||
* @property \Kanboard\Model\ProjectDailyColumnStats $projectDailyColumnStats
|
||||
* @property \Kanboard\Model\ProjectDailyStats $projectDailyStats
|
||||
|
|
@ -121,7 +119,6 @@ use Pimple\Container;
|
|||
* @property \Kanboard\Model\UserNotificationFilter $userNotificationFilter
|
||||
* @property \Kanboard\Model\UserUnreadNotification $userUnreadNotification
|
||||
* @property \Kanboard\Model\UserMetadata $userMetadata
|
||||
* @property \Kanboard\Model\Webhook $webhook
|
||||
* @property \Kanboard\Validator\ActionValidator $actionValidator
|
||||
* @property \Kanboard\Validator\AuthValidator $authValidator
|
||||
* @property \Kanboard\Validator\ColumnValidator $columnValidator
|
||||
|
|
@ -137,7 +134,7 @@ use Pimple\Container;
|
|||
* @property \Kanboard\Validator\SubtaskValidator $subtaskValidator
|
||||
* @property \Kanboard\Validator\SwimlaneValidator $swimlaneValidator
|
||||
* @property \Kanboard\Validator\TaskLinkValidator $taskLinkValidator
|
||||
* @property \Kanboard\Validator\TaskExternalLinkValidator $taskExternalLinkValidator
|
||||
* @property \Kanboard\Validator\ExternalLinkValidator $externalLinkValidator
|
||||
* @property \Kanboard\Validator\TaskValidator $taskValidator
|
||||
* @property \Kanboard\Validator\UserValidator $userValidator
|
||||
* @property \Psr\Log\LoggerInterface $logger
|
||||
|
|
|
|||
|
|
@ -135,23 +135,4 @@ abstract class Base extends \Kanboard\Core\Base
|
|||
|
||||
return $start_column.' IS NOT NULL AND '.$start_column.' > 0 AND ('.implode(' OR ', $conditions).')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Group a collection of records by a column
|
||||
*
|
||||
* @access public
|
||||
* @param array $collection
|
||||
* @param string $column
|
||||
* @return array
|
||||
*/
|
||||
public function groupByColumn(array $collection, $column)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($collection as $item) {
|
||||
$result[$item[$column]][] = $item;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Kanboard\Model;
|
||||
|
||||
/**
|
||||
* Task Overdue Notification model
|
||||
*
|
||||
* @package model
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class OverdueNotification extends Base
|
||||
{
|
||||
/**
|
||||
* Send overdue tasks
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function sendOverdueTaskNotifications()
|
||||
{
|
||||
$tasks = $this->taskFinder->getOverdueTasks();
|
||||
|
||||
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
|
||||
$users = $this->userNotification->getUsersWithNotificationEnabled($project_id);
|
||||
|
||||
foreach ($users as $user) {
|
||||
$this->sendUserOverdueTaskNotifications($user, $project_tasks);
|
||||
}
|
||||
}
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send overdue tasks for a given user
|
||||
*
|
||||
* @access public
|
||||
* @param array $user
|
||||
* @param array $tasks
|
||||
*/
|
||||
public function sendUserOverdueTaskNotifications(array $user, array $tasks)
|
||||
{
|
||||
$user_tasks = array();
|
||||
|
||||
foreach ($tasks as $task) {
|
||||
if ($this->userNotificationFilter->shouldReceiveNotification($user, array('task' => $task))) {
|
||||
$user_tasks[] = $task;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($user_tasks)) {
|
||||
$this->userNotification->sendUserNotification(
|
||||
$user,
|
||||
Task::EVENT_OVERDUE,
|
||||
array('tasks' => $user_tasks, 'project_name' => $tasks[0]['project_name'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,6 @@ class ClassProvider implements ServiceProviderInterface
|
|||
'LastLogin',
|
||||
'Link',
|
||||
'Notification',
|
||||
'OverdueNotification',
|
||||
'PasswordReset',
|
||||
'Project',
|
||||
'ProjectFile',
|
||||
|
|
|
|||
Loading…
Reference in New Issue