Fix search query. #2713

This commit is contained in:
James Cole 2019-10-10 20:50:40 +02:00
parent 22f63fd951
commit 460906fdfe
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 10 additions and 7 deletions

View File

@ -123,10 +123,13 @@ class Search implements SearchInterface
{
$filteredQuery = app('steam')->cleanString($query);
$this->originalQuery = $filteredQuery;
$pattern = '/[[:alpha:]_]*:"?[\p{L}_-]*"?/ui';
$pattern = '/[[:alpha:]_]*:"?[\P{C}_-]*"?/ui';
$matches = [];
preg_match_all($pattern, $filteredQuery, $matches);
var_dump($matches[0]);
exit;
foreach ($matches[0] as $match) {
$this->extractModifier($match);
$filteredQuery = str_replace($match, '', $filteredQuery);
@ -288,12 +291,12 @@ class Search implements SearchInterface
$after = new Carbon($modifier['value']);
$collector->setAfter($after);
break;
case 'created_at':
case 'created_on':
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $modifier['value']));
$createdAt = new Carbon($modifier['value']);
$collector->setCreatedAt($createdAt);
break;
case 'updated_at':
case 'updated_on':
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $modifier['value']));
$updatedAt = new Carbon($modifier['value']);
$collector->setUpdatedAt($updatedAt);

View File

@ -518,8 +518,8 @@ return [
'default_currency' => 'EUR',
'default_language' => 'en_US',
'search_modifiers' => ['amount_is', 'amount', 'amount_max', 'amount_min', 'amount_less', 'amount_more', 'source', 'destination', 'category',
'budget', 'bill', 'type', 'date', 'date_before', 'date_after', 'on', 'before', 'after', 'from', 'to', 'tag', 'created_at',
'updated_at'],
'budget', 'bill', 'type', 'date', 'date_before', 'date_after', 'on', 'before', 'after', 'from', 'to', 'tag', 'created_on',
'updated_on'],
// TODO notes has_attachments
'cer_providers' => [

View File

@ -255,8 +255,8 @@ return [
'search_modifier_on' => 'Transaction date is :value',
'search_modifier_before' => 'Transaction date is before :value',
'search_modifier_after' => 'Transaction date is after :value',
'search_modifier_created_at' => 'Transaction was created on :value',
'search_modifier_updated_at' => 'Transaction was last updated on :value',
'search_modifier_created_on' => 'Transaction was created on :value',
'search_modifier_updated_on' => 'Transaction was last updated on :value',
'modifiers_applies_are' => 'The following modifiers are applied to the search as well:',
'general_search_error' => 'An error occurred while searching. Please check the log files for more information.',
'search_box' => 'Search',