Skip to content

Commit

Permalink
Added a counter for the number of objects that were skipped (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM authored Jan 7, 2023
1 parent b00a59d commit a479d50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ main();

async function main() {
let objectsToSkip = [];
let numObjectsSkipped = 0;
if (CONFIG.skipExisting?.enabled) {
console.log("Skipping existing objects, querying database...");
objectsToSkip = await getPagesToSkipFromNotionDatabase();
Expand All @@ -39,6 +40,7 @@ async function main() {
for (const [inputKey, inputObject] of Object.entries(INPUTFILE)) {
if (CONFIG.skipExisting?.enabled && objectsToSkip.includes(inputObject[CONFIG.skipExisting.jsonKey])) {
progressBar.increment();
numObjectsSkipped++;
continue;
}
try {
Expand Down Expand Up @@ -90,6 +92,10 @@ async function main() {

console.log("\nImport finished.\n");

if (CONFIG.skipExisting?.enabled) {
console.log(`Skipped ${numObjectsSkipped} objects that already existed in the database.`);
}

if (erroredObjects.length > 0) {
console.log("The following objects could not be imported due to either an internal or Notion API error:\n");
console.log(erroredObjects);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "json-to-notion",
"type": "module",
"version": "1.0.0",
"version": "1.1.0",
"description": "Utility that is able to \"import\" JSON files to Notion - for cases where a CSV file is simply not available, and the conversion from JSON to CSV would be too complicated.",
"main": "index.js",
"dependencies": {
Expand Down

0 comments on commit a479d50

Please sign in to comment.