Skip to content

Commit

Permalink
goroutined approach
Browse files Browse the repository at this point in the history
  • Loading branch information
jzyinq committed Mar 30, 2024
1 parent 663e00f commit 8213514
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions gojira/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,35 @@ var IssuesCommand = &cli.Command{
var err error
_ = spinner.New().Title("Fetching issues...").Action(func() {
var funcErr error
app.workLogs, err = GetWorklogs(DayRange(app.time))
if err != nil {
err = funcErr
return
}
issuesWithWorkLogs, funcErr := GetIssuesWithWorklogs(app.workLogs.logs)
if funcErr != nil {
err = funcErr
return
}
lastTickets, funcErr := NewJiraClient().GetLatestIssues()
logrus.Infof("Last tickets: %v", lastTickets.Issues)
if funcErr != nil {
err = funcErr
return
}
combinedIssues := append(issuesWithWorkLogs, lastTickets.Issues...)

var issuesWithWorkLogs []Issue
var lastIssues []Issue
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
defer wg.Done()
app.workLogs, err = GetWorklogs(DayRange(app.time))
if err != nil {
err = funcErr
return
}
issuesWithWorkLogs, funcErr = GetIssuesWithWorklogs(app.workLogs.logs)
if funcErr != nil {
err = funcErr
return
}
}()
go func() {
defer wg.Done()
lastTickets, funcErr := NewJiraClient().GetLatestIssues()
lastIssues = lastTickets.Issues
logrus.Infof("Last tickets: %v", lastIssues)
if funcErr != nil {
err = funcErr
return
}
}()
wg.Wait()
combinedIssues := append(issuesWithWorkLogs, lastIssues...)
uniqueIssueKeys := map[string]bool{}
for _, issue := range combinedIssues {
if _, value := uniqueIssueKeys[issue.Key]; !value {
Expand Down

0 comments on commit 8213514

Please sign in to comment.