Commit f47323ac authored by 贾浩@五瓣科技's avatar 贾浩@五瓣科技

add pass resap

parent b1097bf5
...@@ -61,6 +61,7 @@ type Task struct { ...@@ -61,6 +61,7 @@ type Task struct {
Enable bool `json:"enable"` Enable bool `json:"enable"`
Msg string `json:"msg"` Msg string `json:"msg"`
SubmitTimestamp int `json:"submitTimestamp"` SubmitTimestamp int `json:"submitTimestamp"`
Pass bool `json:"pass"`
} }
type CreateTaskRequest struct { type CreateTaskRequest struct {
......
...@@ -62,6 +62,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G ...@@ -62,6 +62,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
taskResults := make([]apiModel.Task, len(tasks)) taskResults := make([]apiModel.Task, len(tasks))
var wg sync.WaitGroup var wg sync.WaitGroup
var errCh = make(chan error, len(tasks))
for i := range tasks { for i := range tasks {
wg.Add(1) wg.Add(1)
...@@ -80,11 +81,13 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G ...@@ -80,11 +81,13 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
Daily: task.Daily, Daily: task.Daily,
TweetId: task.TweetId, TweetId: task.TweetId,
Enable: task.Enable, Enable: task.Enable,
Pass: task.Pass,
} }
status, submittedAt, err := s.GetTaskResult(_task.Daily, _task.TaskId.(int), userId) status, submittedAt, err := s.GetTaskResult(_task.Daily, _task.TaskId.(int), userId)
if err != nil { if err != nil {
log.WithError(err).Error("group check task") log.WithError(err).Error("group check task")
errCh <- err
return return
} }
_task.Status = status _task.Status = status
...@@ -97,6 +100,12 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G ...@@ -97,6 +100,12 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
} }
wg.Wait() wg.Wait()
if len(errCh) > 0 {
err = <-errCh
close(errCh)
return
}
resp.Tasks = taskResults resp.Tasks = taskResults
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment