drop findCommentID, if it's not in storage a new comment is not bad

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-12-13 10:41:32 +01:00
parent 3310a9bff7
commit 4b3909b79f
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 1 additions and 23 deletions

View File

@ -18,28 +18,6 @@ class Comments {
this.nj.addFilter('date', (data) => (new Date(data)).toLocaleTimeString('utc'))
}
async listComments (pr, per_page = PER_PAGE, sort = 'updated', direction = 'desc') {
/* TODO pagination? */
const rval = await this.gh.issues.listComments({
owner: this.owner,
repo: this.repo,
number: pr,
sort, direction, per_page,
})
return rval.data
}
async findComment (pr) {
const comments = await this.listComments(pr)
/* find comment matching the regex */
return comments.find(c => c.body.match(COMMENT_REGEX))
}
async findCommentID (pr) {
/* we use this as a fallback in case storage failed */
return await this.findComment(pr).id
}
async renderComment (pr) {
const builds = await this.db.getBuilds(pr)
return this.nj.renderString(this.template, {builds})
@ -71,7 +49,7 @@ class Comments {
async update (pr) {
/* check if comment was already posted */
let id = await this.db.getCommentID(pr) || this.findCommentID(pr)
let id = await this.db.getCommentID(pr)
if (id) {
await this.updateComment(pr, id)
} else {