mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-29 20:23:51 -06:00
First attempt at new last activity thing.
This commit is contained in:
parent
3c2952009e
commit
c3dc193f3e
@ -167,10 +167,11 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
$startBalances = Steam::balancesById($ids, $start);
|
$startBalances = Steam::balancesById($ids, $start);
|
||||||
$endBalances = Steam::balancesById($ids, $end);
|
$endBalances = Steam::balancesById($ids, $end);
|
||||||
|
$activities = $repository->getLastActivities($ids);
|
||||||
|
|
||||||
$accounts->each(
|
$accounts->each(
|
||||||
function (Account $account) use ($startBalances, $endBalances) {
|
function (Account $account) use ($activities, $startBalances, $endBalances) {
|
||||||
$account->lastActivityDate = null;//$repository->getLastActivity($account);
|
$account->lastActivityDate = isset($activities[$account->id]) ? $activities[$account->id] : null;
|
||||||
$account->startBalance = isset($startBalances[$account->id]) ? $startBalances[$account->id] : null;
|
$account->startBalance = isset($startBalances[$account->id]) ? $startBalances[$account->id] : null;
|
||||||
$account->endBalance = isset($endBalances[$account->id]) ? $endBalances[$account->id] : null;
|
$account->endBalance = isset($endBalances[$account->id]) ? $endBalances[$account->id] : null;
|
||||||
}
|
}
|
||||||
|
@ -207,6 +207,27 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $accounts
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getLastActivities(array $accounts)
|
||||||
|
{
|
||||||
|
$list = [];
|
||||||
|
|
||||||
|
$set = Auth::user()->transactions()
|
||||||
|
->whereIn('account_id', $accounts)
|
||||||
|
->groupBy('account_id')
|
||||||
|
->get(['transactions.account_id', DB::Raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
|
||||||
|
|
||||||
|
foreach ($set as $entry) {
|
||||||
|
$list[intval($entry->account_id)] = new Carbon($entry->max_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user