From 475a770ea38f512befebe1492453821799469a52 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sun, 12 Oct 2014 08:36:08 +0200 Subject: [PATCH] one less API call --- public/app/js/controllers/BalanceCtrl.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/public/app/js/controllers/BalanceCtrl.js b/public/app/js/controllers/BalanceCtrl.js index ea956ce4..50ba5397 100644 --- a/public/app/js/controllers/BalanceCtrl.js +++ b/public/app/js/controllers/BalanceCtrl.js @@ -100,6 +100,12 @@ app.controller( 'BalanceCtrl', details: {} }; + API.register( { period: period, + categories: '' } ) + .then( function ( response ) { + $scope.balance.details = _($scope.balance.details).extend( _(response.data.values).groupBy('account') ); + } ); + _($scope.balance.buckets).each( function( bucket ) { API.balance( { period: period, categories: bucket.categories } ) @@ -117,11 +123,6 @@ app.controller( 'BalanceCtrl', return memo + account.amount; }, 0 ); } ); - API.register( { period: period, - categories: bucket.categories } ) - .then( function ( response ) { - $scope.balance.details = _($scope.balance.details).extend( _(response.data.values).groupBy('account') ); - } ); } ); };