fix(legacy): fix filename criteria searching (#3068)

### Description

The filename criteria searched the full file path and as such does not
work as expected.

**This is a new feature**:

No

**I have updated the documentation to reflect these changes**:

No docs changes are required as this is fixing a bug to make things work
as expected and documented.

### Testing Notes

**What I did:**

I uploaded some files, and tested that the file name criteria worked as
expected.

**How you can replicate my testing:**

Spin up the stack, upload some files and make sure the filename criteria
works as expected.
This commit is contained in:
dakriy 2024-08-20 14:39:53 -07:00 committed by GitHub
parent f5355d6b61
commit c883d0f2d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 7 deletions

View File

@ -1564,24 +1564,24 @@ SQL;
$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);
@ -1596,6 +1596,11 @@ SQL;
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 {