Refactor task history pagination methods for improved clarity and performance

This commit is contained in:
2025-12-08 19:42:25 -05:00
parent 5191bb53fe
commit 9d672d58ef

View File

@@ -650,20 +650,15 @@ class Statistics extends Component
// Task History Pagination Methods // Task History Pagination Methods
// ========================================== // ==========================================
/**
* Get all task history for pagination (raw data)
*/
public function getAllTaskHistoryProperty(): array
{
return $this->taskHistory;
}
/** /**
* Get paginated task history for display * Get paginated task history for display
*/ */
public function getPaginatedTaskHistoryProperty(): array public function getPaginatedTaskHistoryProperty(): array
{ {
$tasks = $this->allTaskHistory; $tasks = $this->taskHistory;
if (empty($tasks)) {
return [];
}
$offset = ($this->taskHistoryCurrentPage - 1) * $this->taskHistoryPerPage; $offset = ($this->taskHistoryCurrentPage - 1) * $this->taskHistoryPerPage;
return array_slice($tasks, $offset, $this->taskHistoryPerPage); return array_slice($tasks, $offset, $this->taskHistoryPerPage);
@@ -674,7 +669,7 @@ class Statistics extends Component
*/ */
public function getTaskHistoryTotalPagesProperty(): int public function getTaskHistoryTotalPagesProperty(): int
{ {
$total = count($this->allTaskHistory); $total = count($this->taskHistory);
return max(1, (int) ceil($total / $this->taskHistoryPerPage)); return max(1, (int) ceil($total / $this->taskHistoryPerPage));
} }