use findCommentID as a fallback

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

View File

@ -29,17 +29,17 @@ class Comments {
return rval.data
}
async firstComment (pr) {
const rval = await this.listComments(pr, 1, 'created', 'desc')
return rval[0]
}
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 +71,7 @@ class Comments {
async update (pr) {
/* check if comment was already posted */
let id = await this.db.getCommentID(pr)
let id = await this.db.getCommentID(pr) || this.findCommentID(pr)
if (id) {
this.updateComment(pr, id)
} else {