diff --git a/modules/datastore/src/Form/DashboardForm.php b/modules/datastore/src/Form/DashboardForm.php index ac3f2e4c21..6a97e40b86 100644 --- a/modules/datastore/src/Form/DashboardForm.php +++ b/modules/datastore/src/Form/DashboardForm.php @@ -337,9 +337,7 @@ protected function getHarvestLoadStatuses(): \Generator { * Array of harvest load statuses, keyed by dataset UUIDs. */ protected function getHarvestLoadStatus(?string $harvestId): \Generator { - $result = $this->harvest->getHarvestRunResult( - $harvestId, $this->harvest->getLastHarvestRunId($harvestId) - ); + $result = $this->harvest->getHarvestRunResult($harvestId); yield from $result['status']['load'] ?? []; } diff --git a/modules/harvest/src/Entity/HarvestRunRepository.php b/modules/harvest/src/Entity/HarvestRunRepository.php index c404ff927a..d46c855546 100644 --- a/modules/harvest/src/Entity/HarvestRunRepository.php +++ b/modules/harvest/src/Entity/HarvestRunRepository.php @@ -21,16 +21,22 @@ class HarvestRunRepository { /** * Entity storage service for the harvest_run entity type. + * + * @var \Drupal\Core\Entity\EntityStorageInterface */ protected EntityStorageInterface $runStorage; /** * Database connection service. + * + * @var \Drupal\Core\Database\Connection */ private Connection $connection; /** * Harvest run entity definition service. + * + * @var \Drupal\Core\Entity\EntityTypeInterface */ private EntityTypeInterface $entityTypeDefinition; @@ -236,7 +242,7 @@ public function getExtractedUuids(string $planId, string $runId): array { } /** - * Helper method to load a harvest_run entity given an ID and plan ID. + * Helper method to load a harvest_run entity given an Plan ID and timestamp. * * @param string $plan_id * Plan ID. diff --git a/modules/harvest/src/HarvestService.php b/modules/harvest/src/HarvestService.php index e890a2ce57..77c283d541 100644 --- a/modules/harvest/src/HarvestService.php +++ b/modules/harvest/src/HarvestService.php @@ -34,26 +34,36 @@ class HarvestService implements ContainerInjectionInterface { /** * Harvest hash database table factory service. + * + * @var \Contracts\FactoryInterface */ private HarvestHashesDatabaseTableFactory $hashesStoreFactory; /** * DKAN metastore service. + * + * @var \Drupal\metastore\MetastoreService */ private MetastoreService $metastore; /** * Harvest plan storage repository service. + * + * @var \Drupal\harvest\Entity\HarvestPlanRepository */ private HarvestPlanRepository $harvestPlanRepository; /** * Harvest run entity repository service. + * + * @var \Drupal\harvest\Entity\HarvestRunRepository */ public HarvestRunRepository $runRepository; /** * DKAN logger channel. + * + * @var \Psr\Log\LoggerInterface */ private LoggerInterface $logger; @@ -238,21 +248,23 @@ public function getHarvestRunInfo(string $plan_id, string $timestamp): bool|stri * * @param string $plan_id * Harvest plan ID. - * @param string $timestamp + * @param string|null $timestamp * Harvest run timestamp. * * @return array * Array of status info from the run. */ - public function getHarvestRunResult(string $plan_id, string $timestamp): array { - // This one has to keep using the loadEntity method as it may be looking up - // more than the most recent run. - if ($entity = $this->runRepository->loadEntity($plan_id, $timestamp)) { - return $entity->toResult(); + public function getHarvestRunResult(string $plan_id, string|null $timestamp = NULL): array { + if (!is_null($timestamp)) { + // This one has to keep using the loadEntity method as it may be looking + // up something other than the most recent run. + $entity = $this->runRepository->loadEntity($plan_id, $timestamp); } else { - return []; + $entity = $this->runRepository->loadRunByPlan($plan_id); } + + return (!empty($entity)) ? $entity->toResult() : []; } /**