Also return the next_execution_assigned_user for the /chores API endpoint (closes #1493)

Include the user and category object for the /tasks API endpoint (closes #1494)
This commit is contained in:
Bernd Bestel
2021-07-06 18:40:55 +02:00
parent 54bf7ed659
commit aaa054e0a5
3 changed files with 44 additions and 2 deletions

View File

@@ -6,7 +6,32 @@ class TasksService extends BaseService
{
public function GetCurrent(): \LessQL\Result
{
return $this->getDatabase()->tasks_current();
$users = $this->getUsersService()->GetUsersAsDto();
$categories = $this->getDatabase()->task_categories();
$tasks = $this->getDatabase()->tasks_current();
foreach ($tasks as $task)
{
if (!empty($task->assigned_to_user_id))
{
$task->assigned_to_user = FindObjectInArrayByPropertyValue($users, 'id', $task->assigned_to_user_id);
}
else
{
$task->assigned_to_user = null;
}
if (!empty($task->category_id))
{
$task->category = FindObjectInArrayByPropertyValue($categories, 'id', $task->category_id);
}
else
{
$task->category = null;
}
}
return $tasks;
}
public function MarkTaskAsCompleted($taskId, $doneTime)