Skip to content

FOUR-15868 Optimize Task Endpoint for Speed and Efficiency #6897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions ProcessMaker/Http/Controllers/Api/V1_1/TaskController.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
<?php

declare(strict_types=1);

namespace ProcessMaker\Http\Controllers\Api\V1_1;

use Illuminate\Http\Request;
use ProcessMaker\Http\Controllers\Controller;
use ProcessMaker\Models\ProcessRequestToken;

class TaskController extends Controller
{
protected $defaultFields = [
'id',
'element_name',
'due_at',
];

/**
* Display a listing of the resource.
*/
public function index(Request $request)
public function index()
{
$query = ProcessRequestToken::select('id');
$query = ProcessRequestToken::select($this->defaultFields)
->where('element_type', 'task');

return $query->paginate();
}

public function show(ProcessRequestToken $task)
{
return $task;
}
}
4 changes: 4 additions & 0 deletions routes/v1_1/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
// Route to list tasks
Route::get('tasks', [TaskController::class, 'index'])
->name('index');

// Route to show a task
Route::get('tasks/{task}', [TaskController::class, 'show'])
->name('show');
});
});
Loading