mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
addressing performance
This commit is contained in:
parent
10f020405f
commit
925930f76f
@ -37,11 +37,13 @@ func (widget *Widget) content() (string, string, bool) {
|
|||||||
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string {
|
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string {
|
||||||
prs := repo.myPullRequests(username, widget.settings.enableStatus)
|
prs := repo.myPullRequests(username, widget.settings.enableStatus)
|
||||||
|
|
||||||
if len(prs) == 0 {
|
prLength := len(prs)
|
||||||
|
|
||||||
|
if prLength == 0 {
|
||||||
return " [grey]none[white]\n"
|
return " [grey]none[white]\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.SetItemCount(len(prs))
|
widget.SetItemCount(prLength)
|
||||||
|
|
||||||
str := ""
|
str := ""
|
||||||
for idx, pr := range prs {
|
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 {
|
func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPage int) string {
|
||||||
res := repo.customIssueQuery(filter, perPage)
|
res := repo.customIssueQuery(filter, perPage)
|
||||||
|
|
||||||
maxItems := widget.GetItemCount()
|
|
||||||
|
|
||||||
if res == nil {
|
if res == nil {
|
||||||
return " [grey]Invalid Query[white]\n"
|
return " [grey]Invalid Query[white]\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(res.Issues) == 0 {
|
issuesLength := len(res.Issues)
|
||||||
|
|
||||||
|
if issuesLength == 0 {
|
||||||
return " [grey]none[white]\n"
|
return " [grey]none[white]\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxItems := widget.GetItemCount()
|
||||||
|
|
||||||
str := ""
|
str := ""
|
||||||
for idx, issue := range res.Issues {
|
for idx, issue := range res.Issues {
|
||||||
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, maxItems + idx , *issue.Number, *issue.Title)
|
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, maxItems + idx , *issue.Number, *issue.Title)
|
||||||
str += "\n"
|
str += "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.SetItemCount(maxItems + len(res.Issues))
|
widget.SetItemCount(maxItems + issuesLength)
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
@ -79,19 +83,21 @@ func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPag
|
|||||||
func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string) string {
|
func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string) string {
|
||||||
prs := repo.myReviewRequests(username)
|
prs := repo.myReviewRequests(username)
|
||||||
|
|
||||||
maxItems := widget.GetItemCount()
|
prLength := len(prs)
|
||||||
|
|
||||||
if len(prs) == 0 {
|
if prLength == 0 {
|
||||||
return " [grey]none[white]\n"
|
return " [grey]none[white]\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxItems := widget.GetItemCount()
|
||||||
|
|
||||||
str := ""
|
str := ""
|
||||||
for idx, pr := range prs {
|
for idx, pr := range prs {
|
||||||
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, maxItems + idx, *pr.Number, *pr.Title)
|
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, maxItems + idx, *pr.Number, *pr.Title)
|
||||||
str += "\n"
|
str += "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.SetItemCount(maxItems + len(prs))
|
widget.SetItemCount(maxItems + prLength)
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user