051-entra-group-directory-cache #57
@ -45,6 +45,8 @@ public function createRun(
|
||||
array $itemIds,
|
||||
int $totalItems
|
||||
): BulkOperationRun {
|
||||
$effectiveTotalItems = max($totalItems, count($itemIds));
|
||||
|
||||
$run = BulkOperationRun::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'user_id' => $user->id,
|
||||
@ -52,7 +54,7 @@ public function createRun(
|
||||
'action' => $action,
|
||||
'status' => 'pending',
|
||||
'item_ids' => $itemIds,
|
||||
'total_items' => $totalItems,
|
||||
'total_items' => $effectiveTotalItems,
|
||||
'processed_items' => 0,
|
||||
'succeeded' => 0,
|
||||
'failed' => 0,
|
||||
@ -66,7 +68,7 @@ public function createRun(
|
||||
context: [
|
||||
'metadata' => [
|
||||
'bulk_run_id' => $run->id,
|
||||
'total_items' => $totalItems,
|
||||
'total_items' => $effectiveTotalItems,
|
||||
],
|
||||
],
|
||||
actorId: $user->id,
|
||||
@ -139,6 +141,14 @@ public function complete(BulkOperationRun $run): void
|
||||
{
|
||||
$run->refresh();
|
||||
|
||||
if ($run->processed_items > $run->total_items) {
|
||||
BulkOperationRun::query()
|
||||
->whereKey($run->id)
|
||||
->update(['total_items' => $run->processed_items]);
|
||||
|
||||
$run->refresh();
|
||||
}
|
||||
|
||||
if (! in_array($run->status, ['pending', 'running'], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
@if($runs->isNotEmpty())
|
||||
<div class="fixed bottom-4 right-4 z-[999999] w-96 space-y-2" style="pointer-events: auto;">
|
||||
@foreach ($runs as $run)
|
||||
@php($effectiveTotal = max((int) $run->total_items, (int) $run->processed_items))
|
||||
@php($percent = $effectiveTotal > 0 ? min(100, round(($run->processed_items / $effectiveTotal) * 100)) : 0)
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl border-2 border-primary-500 dark:border-primary-400 p-4 transition-all animate-in slide-in-from-right duration-300"
|
||||
wire:key="run-{{ $run->id }}">
|
||||
|
||||
@ -38,17 +40,17 @@
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<span class="text-xs font-medium text-gray-700 dark:text-gray-300">
|
||||
{{ $run->processed_items }} / {{ $run->total_items }}
|
||||
{{ $run->processed_items }} / {{ $effectiveTotal }}
|
||||
</span>
|
||||
<div class="text-xs text-gray-500 dark:text-gray-400 mt-0.5">
|
||||
{{ $run->total_items > 0 ? round(($run->processed_items / $run->total_items) * 100) : 0 }}%
|
||||
{{ $percent }}%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="w-full bg-gray-200 rounded-full h-3 dark:bg-gray-700 overflow-hidden">
|
||||
<div class="bg-primary-600 dark:bg-primary-500 h-3 rounded-full transition-all duration-300 ease-out"
|
||||
style="width: {{ $run->total_items > 0 ? ($run->processed_items / $run->total_items) * 100 : 0 }}%"></div>
|
||||
style="width: {{ $percent }}%"></div>
|
||||
</div>
|
||||
|
||||
<div class="mt-2 flex items-center justify-between text-xs">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user