Add command line argument to filter overdue notification for a given project
This commit is contained in:
@@ -7,6 +7,7 @@ New features:
|
|||||||
* Add the possibility to create a comment when a task is sent by email
|
* Add the possibility to create a comment when a task is sent by email
|
||||||
* Add dropdown menu to autocomplete email field from project members
|
* Add dropdown menu to autocomplete email field from project members
|
||||||
* Add configurable list of predefined subjects when sending a task or a a comment by email
|
* Add configurable list of predefined subjects when sending a task or a a comment by email
|
||||||
|
* Add command line argument to filter overdue notification for a given project
|
||||||
|
|
||||||
Version 1.0.44 (May 28, 2017)
|
Version 1.0.44 (May 28, 2017)
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Kanboard\Console;
|
namespace Kanboard\Console;
|
||||||
|
|
||||||
|
use Kanboard\Model\ProjectModel;
|
||||||
use Kanboard\Model\TaskModel;
|
use Kanboard\Model\TaskModel;
|
||||||
use Kanboard\Core\Security\Role;
|
use Kanboard\Core\Security\Role;
|
||||||
use Symfony\Component\Console\Helper\Table;
|
use Symfony\Component\Console\Helper\Table;
|
||||||
@@ -18,17 +19,30 @@ class TaskOverdueNotificationCommand extends BaseCommand
|
|||||||
->setDescription('Send notifications for overdue tasks')
|
->setDescription('Send notifications for overdue tasks')
|
||||||
->addOption('show', null, InputOption::VALUE_NONE, 'Show sent overdue tasks')
|
->addOption('show', null, InputOption::VALUE_NONE, 'Show sent overdue tasks')
|
||||||
->addOption('group', null, InputOption::VALUE_NONE, 'Group all overdue tasks for one user (from all projects) in one email')
|
->addOption('group', null, InputOption::VALUE_NONE, 'Group all overdue tasks for one user (from all projects) in one email')
|
||||||
->addOption('manager', null, InputOption::VALUE_NONE, 'Send all overdue tasks to project manager(s) in one email');
|
->addOption('manager', null, InputOption::VALUE_NONE, 'Send all overdue tasks to project manager(s) in one email')
|
||||||
|
->addOption('project', 'p', InputOption::VALUE_REQUIRED, 'Send notifications only the given project')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
if ($input->getOption('group')) {
|
if ($input->getOption('project')) {
|
||||||
$tasks = $this->sendGroupOverdueTaskNotifications();
|
$tasks = $this->taskFinderModel->getOverdueTasksQuery()
|
||||||
} elseif ($input->getOption('manager')) {
|
->beginOr()
|
||||||
$tasks = $this->sendOverdueTaskNotificationsToManagers();
|
->eq(TaskModel::TABLE.'.project_id', $input->getOption('project'))
|
||||||
|
->eq(ProjectModel::TABLE.'.identifier', $input->getOption('project'))
|
||||||
|
->closeOr()
|
||||||
|
->findAll();
|
||||||
} else {
|
} else {
|
||||||
$tasks = $this->sendOverdueTaskNotifications();
|
$tasks = $this->taskFinderModel->getOverdueTasks();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input->getOption('group')) {
|
||||||
|
$tasks = $this->sendGroupOverdueTaskNotifications($tasks);
|
||||||
|
} elseif ($input->getOption('manager')) {
|
||||||
|
$tasks = $this->sendOverdueTaskNotificationsToManagers($tasks);
|
||||||
|
} else {
|
||||||
|
$tasks = $this->sendOverdueTaskNotifications($tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('show')) {
|
if ($input->getOption('show')) {
|
||||||
@@ -62,11 +76,11 @@ class TaskOverdueNotificationCommand extends BaseCommand
|
|||||||
* Send all overdue tasks for one user in one email
|
* Send all overdue tasks for one user in one email
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param array $tasks
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function sendGroupOverdueTaskNotifications()
|
public function sendGroupOverdueTaskNotifications(array $tasks)
|
||||||
{
|
{
|
||||||
$tasks = $this->taskFinderModel->getOverdueTasks();
|
|
||||||
|
|
||||||
foreach ($this->groupByColumn($tasks, 'owner_id') as $user_tasks) {
|
foreach ($this->groupByColumn($tasks, 'owner_id') as $user_tasks) {
|
||||||
$users = $this->userNotificationModel->getUsersWithNotificationEnabled($user_tasks[0]['project_id']);
|
$users = $this->userNotificationModel->getUsersWithNotificationEnabled($user_tasks[0]['project_id']);
|
||||||
|
|
||||||
@@ -82,18 +96,18 @@ class TaskOverdueNotificationCommand extends BaseCommand
|
|||||||
* Send all overdue tasks in one email to project manager(s)
|
* Send all overdue tasks in one email to project manager(s)
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param array $tasks
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function sendOverdueTaskNotificationsToManagers()
|
public function sendOverdueTaskNotificationsToManagers(array $tasks)
|
||||||
{
|
{
|
||||||
$tasks = $this->taskFinderModel->getOverdueTasks();
|
|
||||||
|
|
||||||
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
|
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
|
||||||
$users = $this->userNotificationModel->getUsersWithNotificationEnabled($project_id);
|
$users = $this->userNotificationModel->getUsersWithNotificationEnabled($project_id);
|
||||||
$managers = array();
|
$managers = array();
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$role = $this->projectUserRoleModel->getUserRole($project_id, $user['id']);
|
$role = $this->projectUserRoleModel->getUserRole($project_id, $user['id']);
|
||||||
if($role == Role::PROJECT_MANAGER) {
|
if ($role == Role::PROJECT_MANAGER) {
|
||||||
$managers[] = $user;
|
$managers[] = $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,11 +124,11 @@ class TaskOverdueNotificationCommand extends BaseCommand
|
|||||||
* Send overdue tasks
|
* Send overdue tasks
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param array $tasks
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function sendOverdueTaskNotifications()
|
public function sendOverdueTaskNotifications(array $tasks)
|
||||||
{
|
{
|
||||||
$tasks = $this->taskFinderModel->getOverdueTasks();
|
|
||||||
|
|
||||||
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
|
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
|
||||||
$users = $this->userNotificationModel->getUsersWithNotificationEnabled($project_id);
|
$users = $this->userNotificationModel->getUsersWithNotificationEnabled($project_id);
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ class TaskFinderModel extends Base
|
|||||||
->eq(ProjectModel::TABLE.'.is_active', 1)
|
->eq(ProjectModel::TABLE.'.is_active', 1)
|
||||||
->eq(TaskModel::TABLE.'.is_active', 1)
|
->eq(TaskModel::TABLE.'.is_active', 1)
|
||||||
->neq(TaskModel::TABLE.'.date_due', 0)
|
->neq(TaskModel::TABLE.'.date_due', 0)
|
||||||
->lte(TaskModel::TABLE.'.date_due', mktime(23, 59, 59));
|
->lte(TaskModel::TABLE.'.date_due', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -133,11 +133,12 @@ Optional parameters:
|
|||||||
- `--show`: Display notifications sent
|
- `--show`: Display notifications sent
|
||||||
- `--group`: Group all overdue tasks for one user (from all projects) in one email
|
- `--group`: Group all overdue tasks for one user (from all projects) in one email
|
||||||
- `--manager`: Send all overdue tasks to project manager(s) in one email
|
- `--manager`: Send all overdue tasks to project manager(s) in one email
|
||||||
|
- `-p|--project project_id|identifier`: Send notifications only for the given project
|
||||||
|
|
||||||
You can also display the overdue tasks with the flag `--show`:
|
You can also display the overdue tasks with the flag `--show`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./kanboard notification:overdue-tasks --show
|
./cli notification:overdue-tasks --show
|
||||||
+-----+---------+------------+------------+--------------+----------+
|
+-----+---------+------------+------------+--------------+----------+
|
||||||
| Id | Title | Due date | Project Id | Project name | Assignee |
|
| Id | Title | Due date | Project Id | Project name | Assignee |
|
||||||
+-----+---------+------------+------------+--------------+----------+
|
+-----+---------+------------+------------+--------------+----------+
|
||||||
@@ -146,6 +147,18 @@ You can also display the overdue tasks with the flag `--show`:
|
|||||||
+-----+---------+------------+------------+--------------+----------+
|
+-----+---------+------------+------------+--------------+----------+
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example to filter by project:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./cli notification:overdue-tasks --project 123
|
||||||
|
```
|
||||||
|
|
||||||
|
Or if you have defined a project identifier:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./cli notification:overdue-tasks --project MY_PROJECT
|
||||||
|
```
|
||||||
|
|
||||||
### Run daily project stats calculation
|
### Run daily project stats calculation
|
||||||
|
|
||||||
This command calculate the statistics of each project:
|
This command calculate the statistics of each project:
|
||||||
|
|||||||
Reference in New Issue
Block a user