(_ context.Context, query RunQuery)
| 1062 | } |
| 1063 | |
| 1064 | func (s *inMemoryManagerStore) ListTaskRuns(_ context.Context, query RunQuery) ([]Run, error) { |
| 1065 | if err := query.Validate("task_run_query"); err != nil { |
| 1066 | return nil, err |
| 1067 | } |
| 1068 | |
| 1069 | normalized := query |
| 1070 | normalized.TaskID = strings.TrimSpace(normalized.TaskID) |
| 1071 | normalized.Status = normalized.Status.Normalize() |
| 1072 | normalized.SessionID = strings.TrimSpace(normalized.SessionID) |
| 1073 | normalized.CoordinationChannelID = strings.TrimSpace(normalized.CoordinationChannelID) |
| 1074 | |
| 1075 | runs := make([]Run, 0) |
| 1076 | for _, run := range s.runs { |
| 1077 | if normalized.TaskID != "" && run.TaskID != normalized.TaskID { |
| 1078 | continue |
| 1079 | } |
| 1080 | if normalized.Status.Normalize() != "" && run.Status != normalized.Status { |
| 1081 | continue |
| 1082 | } |
| 1083 | if normalized.SessionID != "" && run.SessionID != normalized.SessionID { |
| 1084 | continue |
| 1085 | } |
| 1086 | if normalized.CoordinationChannelID != "" && |
| 1087 | run.CoordinationChannelID != normalized.CoordinationChannelID { |
| 1088 | continue |
| 1089 | } |
| 1090 | runs = append(runs, cloneTaskRun(run)) |
| 1091 | } |
| 1092 | sort.Slice(runs, func(i int, j int) bool { |
| 1093 | return runs[i].ID < runs[j].ID |
| 1094 | }) |
| 1095 | if normalized.Limit > 0 && len(runs) > normalized.Limit { |
| 1096 | return append([]Run(nil), runs[:normalized.Limit]...), nil |
| 1097 | } |
| 1098 | return append([]Run(nil), runs...), nil |
| 1099 | } |
| 1100 | |
| 1101 | func (s *inMemoryManagerStore) ListTaskRunsByStatus( |
| 1102 | _ context.Context, |
no test coverage detected