MCPcopy Index your code
hub / github.com/apache/devlake / GetSubTasksInfo

Function GetSubTasksInfo

backend/server/services/task.go:242–333  ·  view source on GitHub ↗

GetSubTasksInfo returns subtask list of the pipeline, only the most recently subtasks would be returned

(pipelineId uint64, shouldSanitize bool, tx dal.Dal)

Source from the content-addressed store, hash-verified

240
241// GetSubTasksInfo returns subtask list of the pipeline, only the most recently subtasks would be returned
242func GetSubTasksInfo(pipelineId uint64, shouldSanitize bool, tx dal.Dal) (*models.SubTasksOuput, errors.Error) {
243 if tx == nil {
244 tx = db
245 }
246 var tasks []*models.Task
247 err := tx.All(&tasks, dal.Where("pipeline_id = ?", pipelineId), dal.Orderby("id"))
248 if err != nil {
249 return nil, err
250 }
251
252 lastTasks := filterTasksWithLastStatus(tasks)
253 var subtasksInfo []models.SubtasksInfo
254 var totalSubtasksCount int64
255 var totalFinishedSubTasksCount int64
256 var count int64
257 var status []string
258 for _, task := range lastTasks {
259 if task.Plugin == "org" || task.Plugin == "refdiff" || task.Plugin == "dora" {
260 continue
261 }
262 subTaskResult := models.SubtasksInfo{
263 ID: task.ID,
264 PipelineID: task.PipelineId,
265 CreatedAt: task.CreatedAt,
266 UpdatedAt: task.UpdatedAt,
267 BeganAt: task.BeganAt,
268 FinishedAt: task.FinishedAt,
269 Plugin: task.Plugin,
270 Status: task.Status,
271 Message: task.Message,
272 ErrorName: task.ErrorName,
273 SpentSeconds: task.SpentSeconds,
274 }
275 if shouldSanitize {
276 taskOption, err := SanitizePluginOption(task.Plugin, task.Options)
277 if err != nil {
278 return nil, errors.Convert(err)
279 }
280 subTaskResult.Options = taskOption
281 }
282
283 subtasks := []*models.Subtask{}
284 err = tx.All(&subtasks, dal.Where("task_id = ?", task.ID))
285 if err != nil {
286 return nil, err
287 }
288 for _, subtask := range subtasks {
289 t := &models.SubtaskDetails{
290 ID: subtask.ID,
291 CreatedAt: subtask.CreatedAt,
292 UpdatedAt: subtask.UpdatedAt,
293 TaskID: subtask.TaskID,
294 Name: subtask.Name,
295 Number: subtask.Number,
296 BeganAt: subtask.BeganAt,
297 FinishedAt: subtask.FinishedAt,
298 SpentSeconds: subtask.SpentSeconds,
299 FinishedRecords: subtask.FinishedRecords,

Callers

nothing calls this directly

Calls 7

SanitizePluginOptionFunction · 0.85
getTaskStatusFunction · 0.85
AllMethod · 0.65
CountMethod · 0.65
FromMethod · 0.65
ConvertMethod · 0.45

Tested by

no test coverage detected