(ctx context.Context, platform constant.TaskPlatform, channelId int, taskIds []string, taskM map[string]*model.Task)
| 22 | } |
| 23 | |
| 24 | func updateVideoTaskAll(ctx context.Context, platform constant.TaskPlatform, channelId int, taskIds []string, taskM map[string]*model.Task) error { |
| 25 | common.LogInfo(ctx, fmt.Sprintf("Channel #%d pending video tasks: %d", channelId, len(taskIds))) |
| 26 | if len(taskIds) == 0 { |
| 27 | return nil |
| 28 | } |
| 29 | cacheGetChannel, err := model.CacheGetChannel(channelId) |
| 30 | if err != nil { |
| 31 | errUpdate := model.TaskBulkUpdate(taskIds, map[string]any{ |
| 32 | "fail_reason": fmt.Sprintf("Failed to get channel info, channel ID: %d", channelId), |
| 33 | "status": "FAILURE", |
| 34 | "progress": "100%", |
| 35 | }) |
| 36 | if errUpdate != nil { |
| 37 | common.SysError(fmt.Sprintf("UpdateVideoTask error: %v", errUpdate)) |
| 38 | } |
| 39 | return fmt.Errorf("CacheGetChannel failed: %w", err) |
| 40 | } |
| 41 | adaptor := relay.GetTaskAdaptor(platform) |
| 42 | if adaptor == nil { |
| 43 | return fmt.Errorf("video adaptor not found") |
| 44 | } |
| 45 | for _, taskId := range taskIds { |
| 46 | if err := updateVideoSingleTask(ctx, adaptor, cacheGetChannel, taskId, taskM); err != nil { |
| 47 | common.LogError(ctx, fmt.Sprintf("Failed to update video task %s: %s", taskId, err.Error())) |
| 48 | } |
| 49 | } |
| 50 | return nil |
| 51 | } |
| 52 | |
| 53 | func updateVideoSingleTask(ctx context.Context, adaptor channel.TaskAdaptor, channel *model.Channel, taskId string, taskM map[string]*model.Task) error { |
| 54 | baseURL := constant.ChannelBaseURLs[channel.Type] |
no test coverage detected