Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Prev Previous commit
Next Next commit
Add an extra function for populating notes
  • Loading branch information
hkmoon committed Jul 7, 2020
commit 034f5caf87178c76e36777e5ab1f75357f841be2
41 changes: 41 additions & 0 deletions src/models/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,38 @@ class report extends Base {
return promise;
}

/**
* process all notes the given input
* @param input
* @param model
* @param advance
* @returns {*|Promise}
*/
processNote(input, model, advance = false) {
let collect = [];

let promise = this.parallel(this[input], (data, done) => {

let item = new model(this.config, data);
item.project_namespace = this.projects[item.project_id];

item.getNotes()
.then(() => {
collect.push(item);

if (advance) advance();
return done();
});


// collect items, query times & stats
collect.push();
});

promise.then(() => this[input] = collect);
return promise;
}

/**
* merge another report into this report
* @param report
Expand All @@ -164,6 +196,15 @@ class report extends Base {
return this.process('issues', Issue, advance);
}

/**
* process notes
* @param advance
* @returns {Promise}
*/
processNotes(advance = false) {
return this.processNote('issues', Issue, advance);
}

/**
* process merge requests
* @param advance
Expand Down