Skip to content

Commit

Permalink
fix(legacy): ensure last played criteria works with never played files (
Browse files Browse the repository at this point in the history
#2840)

### Description

Closes #2798

COALESCE last played null values with date -infinity, to ensure newly
added files are found by the last played smart block criteria.
  • Loading branch information
jooola committed Dec 27, 2023
1 parent d80100a commit 24ee383
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions legacy/application/models/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -1689,31 +1689,22 @@ public function getListofFilesMeetCriteria($showLimit = null)
// need to pull in the current time and subtract the value or figure out how to make it relative
$relativedate = new DateTime($spCriteriaValue);
$dt = $relativedate->format(DateTime::ISO8601);
// Logging::info($spCriteriaValue);
$spCriteriaValue = "{$spCriteria} <= '{$dt}'";
$spCriteriaValue = "COALESCE({$spCriteria}, DATE '-infinity') <= '{$dt}'";
} elseif ($spCriteriaModifier == 'after') {
$relativedate = new DateTime($spCriteriaValue);
$dt = $relativedate->format(DateTime::ISO8601);
// Logging::info($spCriteriaValue);
$spCriteriaValue = "{$spCriteria} >= '{$dt}'";
$spCriteriaValue = "COALESCE({$spCriteria}, DATE '-infinity') >= '{$dt}'";
} elseif ($spCriteriaModifier == 'between') {
$fromrelativedate = new DateTime($spCriteriaValue);
$fdt = $fromrelativedate->format(DateTime::ISO8601);
// Logging::info($fdt);

$torelativedate = new DateTime($spCriteriaExtra);
$tdt = $torelativedate->format(DateTime::ISO8601);
// Logging::info($tdt);
$spCriteriaValue = "{$spCriteria} >= '{$fdt}' AND {$spCriteria} <= '{$tdt}'";
$spCriteriaValue = "COALESCE({$spCriteria}, DATE '-infinity') >= '{$fdt}' AND COALESCE({$spCriteria}, DATE '-infinity') <= '{$tdt}'";
}
// logging::info('before');
// logging::info($spCriteriaModifier);

$spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];

// logging::info('after');
// logging::info($spCriteriaModifier);

try {
if ($spCriteria == 'owner_id') {
$spCriteria = 'subj.login';
Expand Down

0 comments on commit 24ee383

Please sign in to comment.