diff --git a/modules/datastore/src/Form/DashboardForm.php b/modules/datastore/src/Form/DashboardForm.php
index 26d87fdf44..869983f31f 100644
--- a/modules/datastore/src/Form/DashboardForm.php
+++ b/modules/datastore/src/Form/DashboardForm.php
@@ -469,7 +469,7 @@ protected function buildResourcesRow($dist): array {
'#file_path' => UrlHostTokenResolver::resolve($dist['source_path']),
],
],
- $this->buildStatusCell($dist['fetcher_status'], $dist['fetcher_percent_done']),
+ $this->buildStatusCell($dist['fetcher_status']),
$this->buildStatusCell($dist['importer_status'], $dist['importer_percent_done'], $this->cleanUpError($dist['importer_error'])),
$this->buildPostImportStatusCell($status, $error),
];
@@ -482,7 +482,7 @@ protected function buildResourcesRow($dist): array {
*
* @param string $status
* Current job status.
- * @param int $percentDone
+ * @param int|null $percentDone
* Percent done, 0-100.
* @param null|string $error
* An error message, if any.
@@ -490,12 +490,12 @@ protected function buildResourcesRow($dist): array {
* @return array
* Renderable array.
*/
- protected function buildStatusCell(string $status, int $percentDone, ?string $error = NULL) {
+ protected function buildStatusCell(string $status, ?int $percentDone = NULL, ?string $error = NULL) {
return [
'data' => [
'#theme' => 'datastore_dashboard_status_cell',
'#status' => $status,
- '#percent' => $percentDone,
+ '#percent' => $percentDone ?? NULL,
'#error' => $error,
],
'class' => str_replace('_', '-', $status),
diff --git a/modules/datastore/src/Service/Info/ImportInfo.php b/modules/datastore/src/Service/Info/ImportInfo.php
index 48b04989c8..1aa9a9db4e 100644
--- a/modules/datastore/src/Service/Info/ImportInfo.php
+++ b/modules/datastore/src/Service/Info/ImportInfo.php
@@ -152,10 +152,14 @@ private function getFileName($fileFetcher): string {
* @param \Procrastinator\Job\Job $job
* Either a FileFetcher or Importer object.
*
- * @return float
+ * @return float|null
* Percentage.
*/
- private function getPercentDone(Job $job): float {
+ private function getPercentDone(Job $job): ?float {
+ // If the job is done, but precent < 100, NULL.
+ if ($job->getResult()->getStatus() == Result::DONE) {
+ return 100;
+ }
$bytes = $this->getBytesProcessed($job);
$filesize = $this->getFileSize($job);
return ($filesize > 0) ? round($bytes / $filesize * 100) : 0;
diff --git a/modules/datastore/templates/datastore-dashboard-status-cell.html.twig b/modules/datastore/templates/datastore-dashboard-status-cell.html.twig
index 1ccbde8ebb..c2d4212d2b 100644
--- a/modules/datastore/templates/datastore-dashboard-status-cell.html.twig
+++ b/modules/datastore/templates/datastore-dashboard-status-cell.html.twig
@@ -1 +1 @@
-{{ status }} ({{ error|default(percent ~ '%') }})
\ No newline at end of file
+{{ status }} {% if percent is not null %}({{ error|default(percent ~ '%') }}){% endif %}
\ No newline at end of file
diff --git a/tests/src/Functional/DatasetBTBTest.php b/tests/src/Functional/DatasetBTBTest.php
index 0738d7127f..018fe5159f 100644
--- a/tests/src/Functional/DatasetBTBTest.php
+++ b/tests/src/Functional/DatasetBTBTest.php
@@ -454,6 +454,12 @@ private function datastoreImportAndQuery() {
$this->runQueues(['localize_import', 'datastore_import']);
+ // Assert dataset info shows 100%
+ $datasetInfoService = $this->container->get('dkan.common.dataset_info');
+ $metadata = $datasetInfoService->gather($dataset->identifier);
+ $dist = array_shift($metadata['latest_revision']['distributions']);
+ $this->assertEquals(100, $dist['fetcher_percent_done']);
+
$queryString = '[SELECT * FROM ' . $this->getResourceDatastoreTable($resource) . '][WHERE lon = "61.33"][ORDER BY lat DESC][LIMIT 1 OFFSET 0];';
$this->queryResource($resource, $queryString);
}