fix handle retry button

This commit is contained in:
arifal
2025-03-25 15:54:02 +07:00
parent e7950e22f2
commit 091b1f305e
10 changed files with 234 additions and 42 deletions

View File

@@ -158,8 +158,6 @@ class ServicePbgTask
]);
}
Log::info("Page {$currentPage} fetched & saved", ['records' => count($saved_data)]);
$currentPage++;
} while ($currentPage <= $totalPage);

View File

@@ -19,6 +19,7 @@ class ServiceTabPbgTask
private $service_token;
private $user_token;
private $user_refresh_token;
protected $current_uuid = null;
public function __construct(Client $client, ServiceTokenSIMBG $service_token)
{
@@ -34,25 +35,42 @@ class ServiceTabPbgTask
$this->user_refresh_token = $auth_data['refresh'];
}
public function run_service()
public function run_service($retry_uuid = null)
{
try {
$pbg_tasks = PbgTask::all();
$pbg_tasks = PbgTask::orderBy('id')->get();
$start = false;
foreach ($pbg_tasks as $pbg_task) {
$this->scraping_task_assignments($pbg_task->uuid);
$this->scraping_task_retributions($pbg_task->uuid);
$this->scraping_task_integrations($pbg_task->uuid);
if($retry_uuid){
if($pbg_task->uuid === $retry_uuid){
$start = true;
}
// Process task assignments here if needed
Log::info("Successfully fetched for UUID: {$pbg_task->uuid}");
if(!$start){
continue;
}
}
try{
$this->current_uuid = $pbg_task->uuid;
$this->scraping_task_assignments($pbg_task->uuid);
$this->scraping_task_retributions($pbg_task->uuid);
$this->scraping_task_integrations($pbg_task->uuid);
}catch(\Exception $e){
Log::error("Failed on UUID: {$this->current_uuid}, Error: " . $e->getMessage());
throw $e;
}
}
} catch (\Exception $e) {
Log::error("Failed to scrape task assignments: " . $e->getMessage());
Log::error("Failed to syncronize: " . $e->getMessage());
throw $e;
}
}
public function getFailedUUID(){
return $this->current_uuid;
}
private function scraping_task_assignments($uuid)
{
$url = "{$this->simbg_host}/api/pbg/v1/list-tim-penilai/{$uuid}/?page=1&size=10";