forked from pouchcontainer/pouchrobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Group pouchcontainer#6 Fix Issue pouchcontainer#30
Add backend interface for closing 30-day expired issues.
- Loading branch information
shuiwei
committed
Jul 10, 2018
1 parent
3bd9148
commit 8c86f3e
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package issueProcessor | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/google/go-github/github" | ||
"github.com/pouchcontainer/pouchrobot/utils" | ||
) | ||
|
||
func (ip *IssueProcessor) ActToIssueExpired(issue *github.Issue) error { | ||
ip.ActToCloseExpire(issue) | ||
return nil | ||
} | ||
|
||
func (ip *IssueProcessor) ActToCloseExpire(issue *github.Issue) error { | ||
now = time.Now() | ||
d, _ := time.ParseDuration("-24h") | ||
d30 := now.add(30 * d) | ||
|
||
if _, exist := ip.Client.IssueHasComment(*(issue.Number), utils.IssueNeedP1CommentSubStr); exist { | ||
if res := d30.Sub(issue.UpdatedAt); res.Duation < 0 { | ||
return nil | ||
} | ||
} else if _, exist := ip.Client.IssueHasComment(*(issue.Number), utils.IssueNeedP1CommentSubStr); !exist { | ||
return nil | ||
} | ||
|
||
body := fmt.Sprintf(utils.IssueNeedP1Comment, *(issue.User.Login)) | ||
newComment := &github.IssueComment{ | ||
Body: &body, | ||
} | ||
|
||
return ip.Client.CloseExpireIssues(*(issue.Number)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters