Skip to content

Commit

Permalink
DKAN-4287 Restore Import Status table display.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Wirt authored and Steve Wirt committed Jan 9, 2025
1 parent 01d7288 commit 5a7b090
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
4 changes: 1 addition & 3 deletions modules/datastore/src/Form/DashboardForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? [];
}

Expand Down
8 changes: 7 additions & 1 deletion modules/harvest/src/Entity/HarvestRunRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
26 changes: 19 additions & 7 deletions modules/harvest/src/HarvestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 $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() : [];
}

/**
Expand Down

0 comments on commit 5a7b090

Please sign in to comment.