Skip to content

Commit

Permalink
support Jira GDPR changes. Fix but where job stops on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kobaly committed Apr 8, 2020
1 parent 31d8721 commit 30e2273
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
12 changes: 6 additions & 6 deletions jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ type UpdatedWorklogs struct {
type Worklog struct {
Self string `json:"self"`
Author struct {
Self string `json:"self"`
Name string `json:"name"`
Key string `json:"key"`
AccountID string `json:"accountId"`
EmailAddress string `json:"emailAddress"`
AvatarUrls struct {
Self string `json:"self"`
//Name string `json:"name"`
//Key string `json:"key"`
AccountID string `json:"accountId"`
//EmailAddress string `json:"emailAddress"`
AvatarUrls struct {
Four8X48 string `json:"48x48"`
Two4X24 string `json:"24x24"`
One6X16 string `json:"16x16"`
Expand Down
7 changes: 4 additions & 3 deletions job/JiraWorklogsDownloader.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package job

import (
"strings"
"time"

"github.com/mkobaly/jiraworklog"
"github.com/mkobaly/jiraworklog/repository"
"github.com/mkobaly/jiraworklog/types"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"strings"
"time"
)

//JiraWorklogsDownloader is a background job that will download all worklogs from Jira
Expand Down Expand Up @@ -115,7 +116,7 @@ func (j *JiraWorklogsDownloader) okToProcess(w jiraworklog.Worklog, userNames []
}

for _, u := range userNames {
if strings.ToLower(w.Author.Key) == strings.ToLower(u) {
if strings.ToLower(w.Author.DisplayName) == strings.ToLower(u) {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion types/worklogItem.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func ConvertToModels(w jiraworklog.Worklog, i jiraworklog.Issue, parentIssue jir

worklogResult := &WorklogItem{
ID: id,
Author: w.Author.Key,
Author: w.Author.DisplayName,
Project: strings.Split(i.Key, "-")[0],
IssueID: issueID,
IssueKey: i.Key,
Expand Down
11 changes: 7 additions & 4 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ func (w *Worker) Start() {
//Run will execute the given job
func (w *Worker) Run(job Job) {
for {
hasError := false
started := time.Now()
err := job.Run()
if err != nil {
w.logger.WithError(err).WithField("job", job.GetName()).Error("job run failed")
return
hasError = true
}
if !hasError {
finished := time.Now()
duration := finished.Sub(started)
w.logger.WithField("duration", duration).WithField("job", job.GetName()).Info("job run complete")
}
finished := time.Now()
duration := finished.Sub(started)
w.logger.WithField("duration", duration).WithField("job", job.GetName()).Info("job run complete")

select {
case <-w.stopChan:
Expand Down

0 comments on commit 30e2273

Please sign in to comment.