diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 64d1d22701..3a7f9dd1c4 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -43,9 +43,6 @@ use View; class TagController extends Controller { - /** @var array */ - public $tagOptions = []; - /** @var TagRepositoryInterface */ protected $repository; @@ -60,17 +57,8 @@ class TagController extends Controller $this->middleware( function ($request, $next) { $this->repository = app(TagRepositoryInterface::class); - $this->tagOptions = [ - 'nothing' => trans('firefly.regular_tag'), - 'balancingAct' => trans('firefly.balancing_act'), - 'advancePayment' => trans('firefly.advance_payment'), - ]; - - View::share('title', strval(trans('firefly.tags'))); View::share('mainTitleIcon', 'fa-tags'); - View::share('tagOptions', $this->tagOptions); - return $next($request); } diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index d48d277ea6..4a5b350a27 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -275,17 +275,23 @@ class TagRepository implements TagRepositoryInterface $max = 0; $query = $this->user->tags(); $return = []; + Log::debug('Going to build tag-cloud'); if (!is_null($year)) { + Log::debug(sprintf('Year is not null: %d', $year)); $start = $year . '-01-01'; $end = $year . '-12-31'; $query->where('date', '>=', $start)->where('date', '<=', $end); } if (is_null($year)) { $query->whereNull('date'); + Log::debug('Year is NULL'); } $tags = $query->orderBy('id', 'desc')->get(); $temporary = []; + Log::debug(sprintf('Found %d tags', $tags->count())); + /** @var Tag $tag */ foreach ($tags as $tag) { + $amount = floatval($this->sumOfTag($tag, null, null)); $min = $amount < $min || is_null($min) ? $amount : $min; $max = $amount > $max ? $amount : $max; @@ -293,6 +299,8 @@ class TagRepository implements TagRepositoryInterface 'amount' => $amount, 'tag' => $tag, ]; + Log::debug(sprintf('Now working on tag %s with total amount %s', $tag->tag, $amount)); + Log::debug(sprintf('Minimum is now %f, maximum is %f', $min, $max)); } /** @var array $entry */ foreach ($temporary as $entry) { @@ -304,6 +312,8 @@ class TagRepository implements TagRepositoryInterface ]; } + Log::debug('DONE with tagcloud'); + return $return; } @@ -337,7 +347,16 @@ class TagRepository implements TagRepositoryInterface */ private function cloudScale(array $range, float $amount, float $min, float $max): int { + Log::debug(sprintf('Now in cloudScale with %s as amount and %f min, %f max', $amount, $min, $max)); $amountDiff = $max - $min; + Log::debug(sprintf('AmountDiff is %f', $amountDiff)); + + // no difference? Every tag same range: + if($amountDiff === 0.0) { + Log::debug(sprintf('AmountDiff is zero, return %d', $range[0])); + return $range[0]; + } + $diff = $range[1] - $range[0]; $step = 1; if ($diff != 0) {