-
Notifications
You must be signed in to change notification settings - Fork 3
/
sync_sprint_member_data.go
42 lines (33 loc) · 1.1 KB
/
sync_sprint_member_data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package retrospective
import (
"errors"
"github.com/gocraft/work"
"github.com/iReflect/reflect-app/db"
"github.com/iReflect/reflect-app/workers"
"log"
retroServices "github.com/iReflect/reflect-app/apps/retrospective/services"
)
func init() {
workers.RegisterJob("sync_sprint_member_data", SyncSprintMemberData)
}
// SyncSprintMemberData ...
func SyncSprintMemberData(job *work.Job) error {
sprintService := retroServices.SprintService{DB: db.Initialize(workers.Config)}
sprintID := job.ArgInt64("sprintID")
if sprintID == 0 {
log.Println("Job failed: ", job.Name, " with error: sprintID cannot be zero")
return errors.New("sprintID cannot be zero")
}
sprintMemberID := job.ArgString("sprintMemberID")
if sprintMemberID == "" {
log.Println("Job failed: ", job.Name, " with error: sprintMemberID cannot be blank")
return errors.New("sprintMemberID cannot be blank")
}
err := sprintService.SyncSprintMemberData(uint(sprintID), sprintMemberID)
if err != nil {
log.Println("Job failed: ", job.Name, " with error: ", err)
return err
}
log.Println("Completed job: ", job.Name)
return nil
}