1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

addressing performance

This commit is contained in:
Joel Valentine 2019-08-31 17:24:13 +01:00
parent 10f020405f
commit 925930f76f

View File

@ -37,11 +37,13 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string {
prs := repo.myPullRequests(username, widget.settings.enableStatus)
if len(prs) == 0 {
prLength := len(prs)
if prLength == 0 {
return " [grey]none[white]\n"
}
widget.SetItemCount(len(prs))
widget.SetItemCount(prLength)
str := ""
for idx, pr := range prs {
@ -55,23 +57,25 @@ func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) s
func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPage int) string {
res := repo.customIssueQuery(filter, perPage)
maxItems := widget.GetItemCount()
if res == nil {
return " [grey]Invalid Query[white]\n"
}
if len(res.Issues) == 0 {
issuesLength := len(res.Issues)
if issuesLength == 0 {
return " [grey]none[white]\n"
}
maxItems := widget.GetItemCount()
str := ""
for idx, issue := range res.Issues {
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, maxItems + idx , *issue.Number, *issue.Title)
str += "\n"
}
widget.SetItemCount(maxItems + len(res.Issues))
widget.SetItemCount(maxItems + issuesLength)
return str
}
@ -79,19 +83,21 @@ func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPag
func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string) string {
prs := repo.myReviewRequests(username)
maxItems := widget.GetItemCount()
prLength := len(prs)
if len(prs) == 0 {
if prLength == 0 {
return " [grey]none[white]\n"
}
maxItems := widget.GetItemCount()
str := ""
for idx, pr := range prs {
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, maxItems + idx, *pr.Number, *pr.Title)
str += "\n"
}
widget.SetItemCount(maxItems + len(prs))
widget.SetItemCount(maxItems + prLength)
return str
}