Merge branch '115-project-not-found' into 'develop'
fix: 🐛 handle 404 when gitlab project is not found
See merge request ldc-web/projets/support-web!128
This commit is contained in:
commit
da03fbe273
1 changed files with 37 additions and 10 deletions
|
|
@ -2,16 +2,17 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Ticket;
|
||||
use App\Enums\Tickets\TicketStatusEnum;
|
||||
use App\Models\GitlabIssues;
|
||||
use App\Models\GitlabLabels;
|
||||
use App\Models\GitlabProjects;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\GitlabMilestones;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Enums\Tickets\TicketStatusEnum;
|
||||
use App\Models\GitlabProjects;
|
||||
use App\Models\Ticket;
|
||||
use Carbon\Carbon;
|
||||
use GrahamCampbell\GitLab\Facades\GitLab;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateGitlabDatas extends Command
|
||||
{
|
||||
|
|
@ -226,10 +227,36 @@ class UpdateGitlabDatas extends Command
|
|||
$page = 1;
|
||||
|
||||
do {
|
||||
$milestones = GitLab::milestones()->all($projectId, [
|
||||
'per_page' => 100,
|
||||
'page' => $page
|
||||
]);
|
||||
$milestones = [];
|
||||
|
||||
try {
|
||||
$milestones = GitLab::milestones()->all($projectId, [
|
||||
'per_page' => 100,
|
||||
'page' => $page
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
if ($e->getCode() === 404) {
|
||||
if ($project->delete()) {
|
||||
Log::warning(sprintf(
|
||||
"Project not found (%s), it has been deleted.",
|
||||
$projectId
|
||||
));
|
||||
} else {
|
||||
Log::warning(sprintf(
|
||||
"Project not found (%s).",
|
||||
$projectId
|
||||
));
|
||||
}
|
||||
} else {
|
||||
Log::error(sprintf(
|
||||
'API Error for project %s, Message: %d',
|
||||
$projectId,
|
||||
$e->getMessage()
|
||||
));
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
$allMilestones = array_merge($allMilestones, $milestones);
|
||||
$page++;
|
||||
} while (!empty($milestones));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue