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

Fix DO regen task query conditions (#1643) #1657

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,20 @@ protected function execute($arguments = [], $options = [])

// Only regenerate derivatives for remote digital objects
if ($options['only-externals']) {
$query .= ' AND do.usage_id = '.QubitTerm::EXTERNAL_URI_ID;
array_push($whereClauses, sprintf('do.usage_id = %d', QubitTerm::EXTERNAL_URI_ID));
}

// Only regenerate derivatives for digital objects of specific media type
if ($options['media-type']) {
$query .= ' AND do.media_type_id = '.$validMediaTypes[$options['media-type']];
array_push($whereClauses, sprintf('do.media_type_id = %d', $validMediaTypes[$options['media-type']]));
}

// Limit ids for regeneration by json list
if ($options['json']) {
$ids = json_decode(file_get_contents($options['json']));
$query .= ' AND do.id IN ('.implode(', ', $ids).')';
array_push($whereClauses, 'do.id IN ('.implode(', ', $ids).')');
}

$query .= ' AND do.usage_id != '.QubitTerm::OFFLINE_ID;

if ($options['no-overwrite']) {
$query .= ' LEFT JOIN digital_object child ON do.id = child.parent_id';
array_push($whereClauses, 'do.parent_id IS NULL AND child.id IS NULL');
Expand Down Expand Up @@ -242,6 +240,8 @@ protected function execute($arguments = [], $options = [])
$query .= sprintf(' WHERE %s', implode(' AND ', $whereClauses));
}

$query .= ' AND do.usage_id != '.QubitTerm::OFFLINE_ID;

// Do work
foreach (QubitPdo::fetchAll($query) as $item) {
$do = QubitDigitalObject::getById($item->id);
Expand Down
Loading