mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This commit is contained in:
parent
ebe1fd6142
commit
2b90c20db8
5
.github/workflows/sonarcloud.yml
vendored
5
.github/workflows/sonarcloud.yml
vendored
@ -15,10 +15,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup PHP with Xdebug
|
- name: Setup PHP with Xdebug
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
|
@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\Builder;
|
|||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
use Illuminate\Database\Query\JoinClause;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trait MetaCollection
|
* Trait MetaCollection
|
||||||
@ -663,7 +664,7 @@ trait MetaCollection
|
|||||||
public function setTag(Tag $tag): GroupCollectorInterface
|
public function setTag(Tag $tag): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->withTagInformation();
|
$this->withTagInformation();
|
||||||
$this->query->where('tag_transaction_journal.tag_id', $tag->id);
|
$this->setTags(new Collection([$tag]));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -673,9 +674,38 @@ trait MetaCollection
|
|||||||
*/
|
*/
|
||||||
public function setTags(Collection $tags): GroupCollectorInterface
|
public function setTags(Collection $tags): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
|
Log::debug(sprintf('Now in setTags(%d tag(s))', $tags->count()));
|
||||||
$this->withTagInformation();
|
$this->withTagInformation();
|
||||||
$this->tags = array_merge($this->tags, $tags->pluck('id')->toArray());
|
$this->query->whereNotNull('tag_transaction_journal.tag_id');
|
||||||
$this->query->whereIn('tag_transaction_journal.tag_id', $this->tags);
|
|
||||||
|
// this method adds a "postFilter" to the collector.
|
||||||
|
$list = $tags->pluck('tag')->toArray();
|
||||||
|
$filter = static function (array $object) use ($list): bool {
|
||||||
|
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
|
||||||
|
$expectedTagCount = count($list);
|
||||||
|
$foundTagCount = 0;
|
||||||
|
foreach ($object['transactions'] as $transaction) {
|
||||||
|
$transactionTagCount = count($transaction['tags']);
|
||||||
|
app('log')->debug(sprintf('Transaction has %d tag(s)', $transactionTagCount));
|
||||||
|
if ($transactionTagCount < $expectedTagCount) {
|
||||||
|
app('log')->debug(sprintf('Transaction has %d tag(s), we expect %d tag(s), return false.', $transactionTagCount, $expectedTagCount));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach ($transaction['tags'] as $tag) {
|
||||||
|
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
|
||||||
|
if (in_array(strtolower($tag['name']), $list, true)) {
|
||||||
|
app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name']));
|
||||||
|
++$foundTagCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log::debug(sprintf('Found %d tags, need at least %d.', $foundTagCount, $expectedTagCount));
|
||||||
|
|
||||||
|
// found at least the expected tags.
|
||||||
|
return $foundTagCount >= $expectedTagCount;
|
||||||
|
};
|
||||||
|
$this->postFilters[] = $filter;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -690,10 +720,14 @@ trait MetaCollection
|
|||||||
// this method adds a "postFilter" to the collector.
|
// this method adds a "postFilter" to the collector.
|
||||||
$list = $tags->pluck('tag')->toArray();
|
$list = $tags->pluck('tag')->toArray();
|
||||||
$filter = static function (array $object) use ($list): bool {
|
$filter = static function (array $object) use ($list): bool {
|
||||||
|
Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list)));
|
||||||
foreach ($object['transactions'] as $transaction) {
|
foreach ($object['transactions'] as $transaction) {
|
||||||
app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags'])));
|
app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags'])));
|
||||||
foreach ($transaction['tags'] as $tag) {
|
foreach ($transaction['tags'] as $tag) {
|
||||||
if (in_array($tag['name'], $list, true)) {
|
Log::debug(sprintf('"%s" versus', strtolower($tag['name'])), $list);
|
||||||
|
if (in_array(strtolower($tag['name']), $list, true)) {
|
||||||
|
app('log')->debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name']));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -927,7 +927,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
{
|
{
|
||||||
$currentCollection = $collection;
|
$currentCollection = $collection;
|
||||||
|
|
||||||
// app('log')->debug(sprintf('GroupCollector: postFilterCollection has %d filter(s) and %d transaction(s).', count($this->postFilters), count($currentCollection)));
|
app('log')->debug(sprintf('GroupCollector: postFilterCollection has %d filter(s) and %d transaction(s).', count($this->postFilters), count($currentCollection)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Closure $function
|
* @var \Closure $function
|
||||||
|
Loading…
Reference in New Issue
Block a user