Added searchTasks API procedure
This commit is contained in:
parent
756716766c
commit
da1725c225
|
|
@ -10,6 +10,7 @@ New features:
|
|||
|
||||
Improvements:
|
||||
|
||||
* Added tasks search with the API
|
||||
* Added priority field to API procedures
|
||||
* Added API procedure "getMemberGroups"
|
||||
* Added parameters for overdue tasks notifications: group by projects and send only to managers
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ abstract class Base extends \Kanboard\Core\Base
|
|||
'getBoard',
|
||||
'getProjectActivity',
|
||||
'getOverdueTasksByProject',
|
||||
'searchTasks',
|
||||
);
|
||||
|
||||
public function checkProcedurePermission($is_user, $procedure)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Kanboard\Api;
|
||||
|
||||
use Kanboard\Filter\TaskProjectFilter;
|
||||
use Kanboard\Model\Task as TaskModel;
|
||||
|
||||
/**
|
||||
|
|
@ -12,6 +13,12 @@ use Kanboard\Model\Task as TaskModel;
|
|||
*/
|
||||
class Task extends Base
|
||||
{
|
||||
public function searchTasks($project_id, $query)
|
||||
{
|
||||
$this->checkProjectPermission($project_id);
|
||||
return $this->taskLexer->build($query)->withFilter(new TaskProjectFilter($project_id))->toArray();
|
||||
}
|
||||
|
||||
public function getTask($task_id)
|
||||
{
|
||||
$this->checkTaskPermission($task_id);
|
||||
|
|
|
|||
|
|
@ -636,3 +636,62 @@ Response example:
|
|||
"result": 6
|
||||
}
|
||||
```
|
||||
|
||||
## searchTasks
|
||||
|
||||
- Purpose: **Find tasks by using the search engine**
|
||||
- Parameters:
|
||||
- **project_id** (integer, required)
|
||||
- **query** (string, required)
|
||||
- Result on success: **list of tasks**
|
||||
- Result on failure: **false**
|
||||
|
||||
Request example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "searchTasks",
|
||||
"id": 1468511716,
|
||||
"params": {
|
||||
"project_id": 2,
|
||||
"query": "assignee:nobody"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Response example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1468511716,
|
||||
"result": [
|
||||
{
|
||||
"nb_comments": "0",
|
||||
"nb_files": "0",
|
||||
"nb_subtasks": "0",
|
||||
"nb_completed_subtasks": "0",
|
||||
"nb_links": "0",
|
||||
"nb_external_links": "0",
|
||||
"is_milestone": null,
|
||||
"id": "3",
|
||||
"reference": "",
|
||||
"title": "T3",
|
||||
"description": "",
|
||||
"date_creation": "1461365164",
|
||||
"date_modification": "1461365164",
|
||||
"date_completed": null,
|
||||
"date_started": null,
|
||||
"date_due": "0",
|
||||
"color_id": "yellow",
|
||||
"project_id": "2",
|
||||
"column_id": "5",
|
||||
"swimlane_id": "0",
|
||||
"owner_id": "0",
|
||||
"creator_id": "0"
|
||||
// ...
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,6 +4,26 @@ require_once __DIR__.'/Base.php';
|
|||
|
||||
class TaskTest extends Base
|
||||
{
|
||||
public function testSearchTasks()
|
||||
{
|
||||
$project_id1 = $this->app->createProject('My project');
|
||||
$project_id2 = $this->app->createProject('My project');
|
||||
$this->assertNotFalse($project_id1);
|
||||
$this->assertNotFalse($project_id2);
|
||||
|
||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T1')));
|
||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T2')));
|
||||
$this->assertNotFalse($this->app->createTask(array('project_id' => $project_id2, 'title' => 'T3')));
|
||||
|
||||
$tasks = $this->app->searchTasks($project_id1, 't2');
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('T2', $tasks[0]['title']);
|
||||
|
||||
$tasks = $this->app->searchTasks(array('project_id' => $project_id2, 'query' => 'assignee:nobody'));
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertEquals('T3', $tasks[0]['title']);
|
||||
}
|
||||
|
||||
public function testPriorityAttribute()
|
||||
{
|
||||
$project_id = $this->app->createProject('My project');
|
||||
|
|
|
|||
Loading…
Reference in New Issue