Merge pull request #15549 from snipe/fixes/#15548_unify_audit_api_endpoints
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run

Fixes #15548 - unify audit api endpoints
This commit is contained in:
snipe 2024-09-24 18:10:53 +01:00 committed by GitHub
commit c38222e956
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 11 deletions

View file

@ -56,6 +56,11 @@ class AssetsController extends Controller
public function index(Request $request, $action = null, $upcoming_status = null) : JsonResponse | array
{
// This handles the legacy audit endpoints :(
if ($action == 'audit') {
$action = 'audits';
}
$filter_non_deprecable_assets = false;
/**
@ -154,8 +159,8 @@ class AssetsController extends Controller
* Handle due and overdue audits and checkin dates
*/
switch ($action) {
case 'audits':
// Audit (singular) is left over from earlier legacy APIs
case 'audits' :
switch ($upcoming_status) {
case 'due':
$assets->DueForAudit($settings);

View file

@ -495,24 +495,17 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
)->name('api.assets.show.byserial')
->where('any', '.*');
// LEGACY URL - Get assets that are due or overdue for audit
Route::get('audit/{status}',
[
Api\AssetsController::class,
'index'
]
)->name('api.asset.to-audit');
// This gets the "due or overdue" API endpoints for audits and checkins
// This gets the "due or overdue" API endpoints for audit/audits and checkins
Route::get('{action}/{upcoming_status}',
[
Api\AssetsController::class,
'index'
]
)->name('api.assets.list-upcoming')
->where(['action' => 'audits|checkins', 'upcoming_status' => 'due|overdue|due-or-overdue']);
->where(['action' => 'audit|audits|checkins', 'upcoming_status' => 'due|overdue|due-or-overdue']);