one less API call

This commit is contained in:
Gwenhael Le Moine 2014-10-12 08:36:08 +02:00
parent f73a3d20ef
commit 475a770ea3

View file

@ -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') );
} );
} );
};