Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp 216 patching #1

Draft
wants to merge 8 commits into
base: 2.x
Choose a base branch
from
2 changes: 1 addition & 1 deletion modules/common/src/Storage/AbstractDatabaseTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function getNonSerialFields() {
*/
public function remove(string $id) {
$tableName = $this->getTableName();
$this->connection->delete($tableName)
return $this->connection->delete($tableName)
->condition($this->primaryKey(), $id)
->execute();
}
Expand Down
19 changes: 13 additions & 6 deletions modules/datastore/src/Form/DashboardForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,14 @@ protected function buildDatasetRows(array $datasets): array {
// Gather dataset information.
$datasetInfo = $this->datasetInfo->gather($datasetId);
if (empty($datasetInfo['latest_revision'])) {
continue;
$datasetInfo = [
'latest_revision' => [
'uuid' => $datasetId,
'revision_id' => $datasetInfo['notice']
]
];
//continue;

}
// Build a table row using it's details and harvest status.
$datasetRow = $this->buildRevisionRows($datasetInfo, $harvestLoad[$datasetId] ?? 'N/A');
Expand Down Expand Up @@ -378,7 +385,7 @@ protected function buildRevisionRows(array $datasetInfo, string $harvestStatus)
// Create a row for each dataset revision (there could be both a published
// and latest).
foreach (array_values($datasetInfo) as $rev) {
$distributions = $rev['distributions'];
$distributions = $rev['distributions'] ?? [];
// For first distribution, combine with revision information.
$rows[] = array_merge(
$this->buildRevisionRow($rev, count($distributions), $harvestStatus),
Expand Down Expand Up @@ -409,7 +416,7 @@ protected function buildRevisionRows(array $datasetInfo, string $harvestStatus)
protected function buildRevisionRow(array $rev, int $resourceCount, string $harvestStatus) {
return [
[
'rowspan' => $resourceCount,
'rowspan' => $resourceCount !== 0 ? $resourceCount : 1,
'data' => [
'#theme' => 'datastore_dashboard_dataset_cell',
'#uuid' => $rev['uuid'],
Expand All @@ -418,17 +425,17 @@ protected function buildRevisionRow(array $rev, int $resourceCount, string $harv
],
],
[
'rowspan' => $resourceCount,
'rowspan' => $resourceCount !== 0 ? $resourceCount : 1,
'class' => $rev['moderation_state'],
'data' => [
'#theme' => 'datastore_dashboard_revision_cell',
'#revision_id' => $rev['revision_id'],
'#modified' => $this->dateFormatter->format(strtotime($rev['modified_date_dkan']), 'short'),
'#modified' => !empty($rev['modified_date_dkan']) ? $this->dateFormatter->format(strtotime($rev['modified_date_dkan']), 'short') : '',
'#moderation_state' => $rev['moderation_state'],
],
],
[
'rowspan' => $resourceCount,
'rowspan' => $resourceCount !== 0 ? $resourceCount : 1,
'data' => $harvestStatus,
'class' => strtolower($harvestStatus),
],
Expand Down
19 changes: 14 additions & 5 deletions modules/harvest/src/Commands/HarvestCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,22 @@ protected function buildPlanFromOpts($opts) {
* @command dkan:harvest:deregister
*/
public function deregister($id) {
try {
if ($this->harvestService->deregisterHarvest($id)) {
$message = "Successfully deregistered the {$id} harvest.";
$this->logger->warning('If you deregister a harvest with published datasets, you will not be able to bulk revert the datasets connected to this harvest.');
if ($this->io()->confirm("Deregister harvest {$id}")) {
try {
if ($this->harvestService->deregisterHarvest($id)) {
$message = "Successfully deregistered the {$id} harvest.";
}
else {
$message = "No harvest {$id} deregistered. Check if it exists.";
}
}
catch (\Exception $e) {
$message = $e->getMessage();
}
}
catch (\Exception $e) {
$message = $e->getMessage();
else {
$message = "Skipped deregistering harvest {$id}";
}

(new ConsoleOutput())->write($message . PHP_EOL);
Expand Down
2 changes: 1 addition & 1 deletion modules/harvest/src/Commands/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private function renderStatusTable($harvest_id, $run_id, $run) {
$table->setHeaders(["item_id", "extract", "transform", "load"]);

foreach ($run['status']['extracted_items_ids'] as $item_id) {
$row = $this->generateItemStatusRow($item_id, $run['status'], $run['errors']);
$row = $this->generateItemStatusRow($item_id, $run['status'], $run['errors'] ?? []);
$table->addRow($row);
}

Expand Down
5 changes: 0 additions & 5 deletions modules/harvest/src/HarvestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ public function registerHarvest($plan) {
* Boolean.
*/
public function deregisterHarvest(string $id) {
try {
$this->revertHarvest($id);
}
catch (\Exception $e) {
}

$plan_store = $this->storeFactory->getInstance("harvest_plans");

Expand Down