mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 22:48:18 +00:00
Implement tag count and fix a count thing.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Config;
|
use Config;
|
||||||
|
use FireflyIII\Models\Tag;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use Input;
|
use Input;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
@@ -37,6 +38,20 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function flush()
|
public function flush()
|
||||||
{
|
{
|
||||||
|
// get all tags.
|
||||||
|
// update all counts:
|
||||||
|
$tags = Tag::get();
|
||||||
|
|
||||||
|
/** @var Tag $tag */
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
foreach ($tag->transactionjournals()->get() as $journal) {
|
||||||
|
$count = $journal->tags()->count();
|
||||||
|
$journal->tag_count = $count;
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Session::clear();
|
Session::clear();
|
||||||
|
|
||||||
return Redirect::route('index');
|
return Redirect::route('index');
|
||||||
@@ -49,8 +64,6 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(AccountRepositoryInterface $repository)
|
public function index(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$types = Config::get('firefly.accountTypesByIdentifier.asset');
|
$types = Config::get('firefly.accountTypesByIdentifier.asset');
|
||||||
$count = $repository->countAccounts($types);
|
$count = $repository->countAccounts($types);
|
||||||
|
|
||||||
|
@@ -158,14 +158,13 @@ class TransactionJournal extends Model
|
|||||||
$amount = $t->amount;
|
$amount = $t->amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$count = $this->tags()->count();
|
|
||||||
|
|
||||||
if ($count === 1) {
|
if ($this->tag_count === 1) {
|
||||||
// get amount for single tag:
|
// get amount for single tag:
|
||||||
$amount = $this->amountByTag($this->tags()->first(), $amount);
|
$amount = $this->amountByTag($this->tags()->first(), $amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($count > 1) {
|
if ($this->tag_count > 1) {
|
||||||
// get amount for either tag.
|
// get amount for either tag.
|
||||||
$amount = $this->amountByTags($amount);
|
$amount = $this->amountByTags($amount);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user