|
9 | 9 | use Psr\Log\LoggerInterface; |
10 | 10 | use Torr\TaskManager\Entity\TaskLog; |
11 | 11 | use Torr\TaskManager\Entity\TaskRun; |
| 12 | +use Torr\TaskManager\Task\DispatchAfterRunTask\DispatchAfterRunTask; |
12 | 13 | use Torr\TaskManager\Task\Task; |
13 | 14 |
|
14 | 15 | final class TaskLogModel |
15 | 16 | { |
| 17 | + public const bool SHOW_ALL_TASKS = true; |
| 18 | + public const bool HIDE_INTERNAL_TASKS = false; |
| 19 | + |
16 | 20 | /** @var EntityRepository<TaskLog> */ |
17 | 21 | private EntityRepository $repository; |
18 | 22 |
|
@@ -61,17 +65,28 @@ public function getLogForTask (Task $task) : TaskLog |
61 | 65 | * |
62 | 66 | * @return TaskLog[] |
63 | 67 | */ |
64 | | - public function getMostRecentEntries (int $limit = 100) : array |
| 68 | + public function getMostRecentEntries ( |
| 69 | + int $limit = 100, |
| 70 | + bool $showAll = self::SHOW_ALL_TASKS, |
| 71 | + ) : array |
65 | 72 | { |
66 | | - $query = $this->repository->createQueryBuilder("task") |
| 73 | + $builder = $this->repository->createQueryBuilder("task") |
67 | 74 | ->select("task, run") |
68 | 75 | ->leftJoin("task.runs", "run") |
69 | 76 | ->addOrderBy("task.timeQueued", "DESC") |
70 | | - ->setMaxResults($limit) |
71 | | - ->getQuery(); |
| 77 | + ->setMaxResults($limit); |
| 78 | + |
| 79 | + if (self::HIDE_INTERNAL_TASKS === $showAll) |
| 80 | + { |
| 81 | + $builder |
| 82 | + ->andWhere("task.taskClass NOT IN (:internalTasks)") |
| 83 | + ->setParameter("internalTasks", [ |
| 84 | + DispatchAfterRunTask::class, |
| 85 | + ]); |
| 86 | + } |
72 | 87 |
|
73 | 88 | /** @var TaskLog[] */ |
74 | | - return (new Paginator($query)) |
| 89 | + return (new Paginator($builder->getQuery())) |
75 | 90 | ->getQuery() |
76 | 91 | ->getResult(); |
77 | 92 | } |
|
0 commit comments