8000 fix(legacy): fix filename criteria searching by dakriy · Pull Request #3068 · libretime/libretime · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(legacy): fix filename criteria searching #3068

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

Merged
merged 2 commits into from
Aug 20, 2024
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
19 changes: 12 additions & 7 deletions legacy/application/models/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -1564,24 +1564,24 @@ public function getListofFilesMeetCriteria($showLimit = null)

$spCriteriaValue = $this->resolveDate($spCriteriaValue);

if ($spCriteriaModifier == 'starts with') {
if ($spCriteriaModifier == CriteriaModifier::STARTS_WITH) {
$spCriteriaValue = "{$spCriteriaValue}%";
} elseif ($spCriteriaModifier == 'ends with') {
} elseif ($spCriteriaModifier == CriteriaModifier::ENDS_WITH) {
$spCriteriaValue = "%{$spCriteriaValue}";
} elseif ($spCriteriaModifier == 'contains' || $spCriteriaModifier == 'does not contain') {
} elseif ($spCriteriaModifier == CriteriaModifier::CONTAINS || $spCriteriaModifier == CriteriaModifier::DOES_NOT_CONTAIN) {
$spCriteriaValue = "%{$spCriteriaValue}%";
} elseif ($spCriteriaModifier == 'is in the range') {
} elseif ($spCriteriaModifier == CriteriaModifier::IS_IN_THE_RANGE) {
$spCriteriaValue = "{$spCriteria} >= '{$spCriteriaValue}' AND {$spCriteria} <= '{$spCriteriaExtra}'";
} elseif ($spCriteriaModifier == 'before') {
} elseif ($spCriteriaModifier == CriteriaModifier::BEFORE) {
// 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);
$spCriteriaValue = "COALESCE({$spCriteria}, DATE '-infinity') <= '{$dt}'";
} elseif ($spCriteriaModifier == 'after') {
} elseif ($spCriteriaModifier == CriteriaModifier::AFTER) {
$relativedate = new DateTime($spCriteriaValue);
$dt = $relativedate->format(DateTime::ISO8601);
$spCriteriaValue = "COALESCE({$spCriteria}, DATE '-infinity') >= '{$dt}'";
} elseif ($spCriteriaModifier == 'between') {
} elseif ($spCriteriaModifier == CriteriaModifier::BETWEEN) {
$fromrelativedate = new DateTime($spCriteriaValue);
$fdt = $fromrelativedate->format(DateTime::ISO8601);

Expand All @@ -1596,6 +1596,11 @@ public function getListofFilesMeetCriteria($showLimit = null)
if ($spCriteria == 'owner_id') {
$spCriteria = 'subj.login';
}

if ($spCriteria == 'filepath') {
$spCriteria = "split_part(filepath, '/', -1)";
}

if ($i > 0 && $prevgroup == $group) {
$qry->addOr($spCriteria, $spCriteriaValue, $spCriteriaModifier);
} else {
Expand Down
Loading
0