-
Notifications
You must be signed in to change notification settings - Fork 7
Vsliv30 3515 creation time filter misbehaviour #57
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
ngaspari
merged 2 commits into
master
from
VSLIV30-3515-Creation-Time-Filter-Misbehaviour
Jul 11, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,10 +42,27 @@ public function execute(Builder $builder, string $column, CategorizedValues $val | |
} | ||
|
||
if ($values->and) { | ||
if ($this->isDate($this->searchParser->type) || $this->isDateTime($this->searchParser->type)) { | ||
if ($this->isDate($this->searchParser->type)) { | ||
foreach ($values->and as $andValue) { | ||
$builder->orWhereDate($column, $andValue); | ||
} | ||
} elseif ($this->isDateTime($this->searchParser->type)) { | ||
foreach ($values->and as $andValue) { | ||
$dateTimeValue = new \DateTime($andValue); | ||
$formattedDateTime = $dateTimeValue->format('Y-m-d H:i:s'); | ||
|
||
if ($dateTimeValue->format('s') === '00') { | ||
$builder->orWhere(function ($query) use ($column, $formattedDateTime) { | ||
$query->whereDate($column, '=', date('Y-m-d', strtotime($formattedDateTime))) | ||
->whereTime($column, '>=', date('H:i', strtotime($formattedDateTime))) | ||
->whereTime($column, '<', date('H:i', strtotime($formattedDateTime . ' +1 minute'))); | ||
}); | ||
} else { | ||
$builder->orWhere(function ($query) use ($column, $formattedDateTime) { | ||
$query->where($column, '=', $formattedDateTime); | ||
}); | ||
Comment on lines
+61
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for nesting....... |
||
} | ||
} | ||
} else { | ||
$builder->whereIn($column, $values->and); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and what if we strictly want to search by second = 0? :)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, someone could search for '000' or '0000' as well :)) so let's change it to
if (preg_match('/^0+$/', $dateTimeValue->format('s'))) {...}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, because it doesn't change things.
Seconds will always be 00 in this case, number of 0 was not the point... :)
The point is that FE only selects up to minutes (and adds 00 as seconds) - so this scenario works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the number of zeros wasn't the point, why mention it ;) Since it was mentioned, I went one step further and satisfied those who would go crazy entering endless zeros ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not mention number of zeroes, but the fact that you can not find a record that strictly has 0 second. :)
for example: 2024-07-11 11:28:00
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we both understood each other in the first run and that's all that matters ;)