Skip to content

Commit

Permalink
adding stop for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
moisbo committed May 24, 2024
1 parent b1b16ce commit b09563d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions elastic-remote-indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
})();
Expand Down
12 changes: 7 additions & 5 deletions lib/Indexer-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,6 +35,7 @@ class Indexer {
this.log = getLogger();
this.objects = {};
this.token = null;
this.stop = stop;
}

async getOauthToken() {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b09563d

Please sign in to comment.