From b09563d7908b6fb6425b0dee74c17f72410e316e Mon Sep 17 00:00:00 2001 From: Moises Sacal Date: Fri, 24 May 2024 11:40:20 +1000 Subject: [PATCH] adding stop for debugging --- elastic-remote-indexer.js | 4 ++-- lib/Indexer-remote.js | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/elastic-remote-indexer.js b/elastic-remote-indexer.js index 7528ed7..5f86f65 100644 --- a/elastic-remote-indexer.js +++ b/elastic-remote-indexer.js @@ -41,8 +41,8 @@ const fetch = require("node-fetch"); assert(Array.isArray(skipCollections), `${skipConfiguration} not an array of strings, please fix.`); } // Create an Indexer and index collections - - const indexer = new Indexer({configuration, client}); + const stop = undefined; //When debugging change stop to limit the indexing to a type integer + const indexer = new Indexer({configuration, client, stop}); await indexer.getOauthToken(); await indexer.findOcflObjects({memberOf: null, conformsTo: indexer.conformsToCollection, skip: skipCollections}); })(); diff --git a/lib/Indexer-remote.js b/lib/Indexer-remote.js index 3ae508d..a31c5bd 100644 --- a/lib/Indexer-remote.js +++ b/lib/Indexer-remote.js @@ -18,7 +18,7 @@ class Indexer { * @param repository * @param client */ - constructor({configuration, client}) { + constructor({configuration, client, stop}) { this.configuration = configuration; this.apiHost = this.configuration.api.structural.host; this.key = configuration.api.structural.key; @@ -35,6 +35,7 @@ class Indexer { this.log = getLogger(); this.objects = {}; this.token = null; + this.stop = stop; } async getOauthToken() { @@ -135,10 +136,11 @@ class Indexer { if (json) { data = data.concat(json.data); offset += 10; - stop += 1; - console.log(stop); - if (stop >= 100) { // Debugging to stop - break; + if (this.stop) { + stop += 1; + if (top >= 100) { // Debugging to stop setup stop when calling this class + break; + } } } else { return data;