Merge pull request #2985 from cmgustavo/feat/updates-csv-limit

Updates getting history to new bws limit
This commit is contained in:
Matias Alejo Garcia 2015-07-14 12:34:06 -03:00
commit 89d74281ad
2 changed files with 23 additions and 7 deletions

View file

@ -46,6 +46,7 @@
"> Updating Wallet... </span>
<span translate ng-show="index.onGoingProcessName == 'scanning'">Scanning Wallet funds...</span>
<span translate ng-show="index.onGoingProcessName == 'recreating'">Recreating Wallet...</span>
<span translate ng-show="index.onGoingProcessName == 'generatingCSV'">Generating .csv file...</span>
</div>
</div>

View file

@ -551,7 +551,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
var fs = require('fs');
fs.writeFile(this.value, data, function(err) {
if (err) {
console.log(err);
$log.debug(err);
}
});
}, false);
@ -561,7 +561,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
function formatDate(date) {
var dateObj = new Date(date);
if (!dateObj) {
log.error('Error formating a date');
$log.debug('Error formating a date');
return 'DateError'
}
if (!dateObj.toJSON()) {
@ -585,21 +585,36 @@ angular.module('copayApp.controllers').controller('indexController', function($r
return str;
}
function getHistory(skip, cb) {
skip = skip || 0;
fc.getTxHistory({
skip: skip,
limit: 100
}, function(err, txs) {
if (err) return cb(err);
if (txs && txs.length > 0) {
allTxs.push(txs);
return getHistory(skip + 100, cb);
}
else {
return cb(null, lodash.flatten(allTxs));
}
});
};
if (isCordova) {
log.info('Not available on mobile');
$log.info('Not available on mobile');
return;
}
var isNode = nodeWebkit.isDefined();
var fc = profileService.focusedClient;
if (!fc.isComplete()) return;
var self = this;
var allTxs = [];
$log.debug('Generating CSV from History');
self.setOngoingProcess('generatingCSV', true);
$timeout(function() {
fc.getTxHistory({
skip: 0,
limit: 1000000000
}, function(err, txs) {
getHistory(null, function(err, txs) {
self.setOngoingProcess('generatingCSV', false);
if (err) {
$log.debug('TxHistory ERROR:', err);