Commit c57fe839 authored by Nicolas Frandeboeuf's avatar Nicolas Frandeboeuf Committed by Nicolas Frandeboeuf
Browse files

Add more info logs about the action being run (fix #563)

parent 76f4035a
Pipeline #17426 passed with stage
in 2 minutes and 21 seconds
......@@ -23,7 +23,8 @@ export const formatDate = formatDate_;
export function makeLogger(prefix) {
return printit({
prefix,
date: true
date: true,
dateFormat: 'YYYY-MM-DD hh:mm:ss:SS'
});
}
......
......@@ -95,6 +95,7 @@ async function retrieveAllAccountsByAccess(access) {
throw new KError("Access' password is not set", 500, errcode);
}
log.info(`Retrieve all accounts from access ${access.bank} with login ${access.login}`);
let sourceAccounts = await handler(access).fetchAccounts(access);
let accounts = [];
for (let accountWeboob of sourceAccounts) {
......@@ -253,8 +254,6 @@ merging as per request`);
throw new KError("Access' password is not set", 500, errcode);
}
let sourceOps = await handler(access).fetchTransactions(access);
let operations = [];
let now = moment().format('YYYY-MM-DDTHH:mm:ss.000Z');
......@@ -278,7 +277,10 @@ merging as per request`);
// Eagerly clear state.
this.newAccountsMap.clear();
// Normalize source information
// Fetch source operations
let sourceOps = await handler(access).fetchTransactions(access);
log.info('Normalizing source information...');
for (let sourceOp of sourceOps) {
let operation = {
......@@ -303,6 +305,7 @@ merging as per request`);
operations.push(operation);
}
log.info('Comparing with database to ignore already known operations…');
let newOperations = [];
for (let operation of operations) {
// Ignore operations coming from unknown accounts.
......@@ -333,12 +336,16 @@ merging as per request`);
let toCreate = newOperations;
newOperations = [];
if (toCreate.length > 0) {
log.info('Creating new operations…');
}
for (let operationToCreate of toCreate) {
let created = await Operation.create(operationToCreate);
newOperations.push(created);
}
// Update account balances.
log.info('Updating accounts balances');
for (let { account, balanceOffset } of accountMap.values()) {
if (balanceOffset) {
log.info(`Account ${account.title} initial balance is going to be resynced, by an
......@@ -356,8 +363,8 @@ offset of ${balanceOffset}.`);
accounts.push(updated);
}
log.info('Informing user new operations have been imported...');
if (numNewOperations > 0) {
log.info(`Informing user ${numNewOperations} new operations have been imported...`);
await notifyNewOperations(access, newOperations, accountMap);
}
......
......@@ -60,7 +60,7 @@ class Poller {
// Ensure checks will continue even if we hit some error during the process.
this.programNextRun();
} catch (err) {
log.error(`Error when preparting the next check: ${err.message}`);
log.error(`Error when preparing the next check: ${err.message}`);
}
await this.updateWeboob();
......
......@@ -112,6 +112,7 @@ function callWeboob(command, access) {
export async function testInstall() {
try {
log.info('Checking that weboob is installed and can actually be called…');
await callWeboob('test');
return true;
} catch (err) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment