Skip to content

Commit

Permalink
chore: add database name to couch2pg sync logs
Browse files Browse the repository at this point in the history
  • Loading branch information
njuguna-n committed Nov 14, 2024
1 parent 42efdcc commit 961fbe3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions couch2pg/src/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ const storeDocs = async (allDocsResult) => {
};

const importChangesBatch = async (couchDb, source) => {
const dbName = couchDb.name.split('/').pop();
const seq = await getSeq(source);
console.info('Downloading CouchDB changes feed from ' + seq);
console.info(`Downloading CouchDB changes feed from ${seq} in ${dbName}`);

let pending;
try {
Expand All @@ -143,17 +144,16 @@ const importChangesBatch = async (couchDb, source) => {
}

const changes = await couchDb.changes({ limit: BATCH_SIZE, since: seq, seq_interval: BATCH_SIZE });
console.log('There are ' + changes.results.length + ' changes to process');
console.log(`There are ${changes.results.length} changes to process in ${dbName}`);

const docsToDelete = [];
const docsToDownload = [];
changes.results.forEach(change => change.deleted ? docsToDelete.push(change) : docsToDownload.push(change));

console.info('There are ' +
docsToDelete.length + ' deletions and ' +
docsToDownload.length + ' new / changed documents');
console.info(`There are ${docsToDelete.length} deletions and ${docsToDownload.length} new changed documents ` +
`in ${dbName}`);

console.log('There are approximately ' + pending + ' changes left');
console.log(`There are approximately ${pending} changes left in ${dbName}`);
await loadAndStoreDocs(couchDb, changes.results);
await storeSeq(changes.last_seq, pending, source);

Expand Down

0 comments on commit 961fbe3

Please sign in to comment.