051-entra-group-directory-cache #57

Merged
ahmido merged 7 commits from 051-entra-group-directory-cache into dev 2026-01-11 23:24:12 +00:00
2 changed files with 17 additions and 5 deletions
Showing only changes of commit c93b6e8bb5 - Show all commits

View File

@ -45,6 +45,8 @@ public function createRun(
array $itemIds, array $itemIds,
int $totalItems int $totalItems
): BulkOperationRun { ): BulkOperationRun {
$effectiveTotalItems = max($totalItems, count($itemIds));
$run = BulkOperationRun::create([ $run = BulkOperationRun::create([
'tenant_id' => $tenant->id, 'tenant_id' => $tenant->id,
'user_id' => $user->id, 'user_id' => $user->id,
@ -52,7 +54,7 @@ public function createRun(
'action' => $action, 'action' => $action,
'status' => 'pending', 'status' => 'pending',
'item_ids' => $itemIds, 'item_ids' => $itemIds,
'total_items' => $totalItems, 'total_items' => $effectiveTotalItems,
'processed_items' => 0, 'processed_items' => 0,
'succeeded' => 0, 'succeeded' => 0,
'failed' => 0, 'failed' => 0,
@ -66,7 +68,7 @@ public function createRun(
context: [ context: [
'metadata' => [ 'metadata' => [
'bulk_run_id' => $run->id, 'bulk_run_id' => $run->id,
'total_items' => $totalItems, 'total_items' => $effectiveTotalItems,
], ],
], ],
actorId: $user->id, actorId: $user->id,
@ -139,6 +141,14 @@ public function complete(BulkOperationRun $run): void
{ {
$run->refresh(); $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)) { if (! in_array($run->status, ['pending', 'running'], true)) {
return; return;
} }

View File

@ -3,6 +3,8 @@
@if($runs->isNotEmpty()) @if($runs->isNotEmpty())
<div class="fixed bottom-4 right-4 z-[999999] w-96 space-y-2" style="pointer-events: auto;"> <div class="fixed bottom-4 right-4 z-[999999] w-96 space-y-2" style="pointer-events: auto;">
@foreach ($runs as $run) @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" <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 }}"> wire:key="run-{{ $run->id }}">
@ -38,17 +40,17 @@
</div> </div>
<div class="text-right"> <div class="text-right">
<span class="text-xs font-medium text-gray-700 dark:text-gray-300"> <span class="text-xs font-medium text-gray-700 dark:text-gray-300">
{{ $run->processed_items }} / {{ $run->total_items }} {{ $run->processed_items }} / {{ $effectiveTotal }}
</span> </span>
<div class="text-xs text-gray-500 dark:text-gray-400 mt-0.5"> <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>
</div> </div>
<div class="w-full bg-gray-200 rounded-full h-3 dark:bg-gray-700 overflow-hidden"> <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" <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>
<div class="mt-2 flex items-center justify-between text-xs"> <div class="mt-2 flex items-center justify-between text-xs">