MCPcopy Create free account
hub / github.com/bytebase/bytebase / ListTaskRunLogs

Method ListTaskRunLogs

backend/store/task_run_log.go:60–106  ·  view source on GitHub ↗
(ctx context.Context, projectID string, taskRunUID int64)

Source from the content-addressed store, hash-verified

58}
59
60func (s *Store) ListTaskRunLogs(ctx context.Context, projectID string, taskRunUID int64) ([]*TaskRunLog, error) {
61 q := qb.Q().Space(`
62 SELECT
63 created_at,
64 payload
65 FROM task_run_log
66 WHERE task_run_log.project = ? AND task_run_log.task_run_id = ?
67 ORDER BY created_at
68 `, projectID, taskRunUID)
69
70 sql, args, err := q.ToSQL()
71 if err != nil {
72 return nil, errors.Wrapf(err, "failed to build sql")
73 }
74
75 rows, err := s.GetDB().QueryContext(ctx, sql, args...)
76 if err != nil {
77 return nil, errors.Wrapf(err, "failed to query task run log")
78 }
79 defer rows.Close()
80
81 var logs []*TaskRunLog
82 for rows.Next() {
83 l := TaskRunLog{
84 Payload: &storepb.TaskRunLog{},
85 }
86 var p []byte
87
88 if err := rows.Scan(
89 &l.T,
90 &p,
91 ); err != nil {
92 return nil, errors.Wrapf(err, "failed to scan")
93 }
94
95 if err := common.ProtojsonUnmarshaler.Unmarshal(p, l.Payload); err != nil {
96 return nil, errors.Wrapf(err, "failed to unmarshal")
97 }
98
99 logs = append(logs, &l)
100 }
101 if err := rows.Err(); err != nil {
102 return nil, errors.Wrapf(err, "failed to query")
103 }
104
105 return logs, nil
106}

Callers 2

GetTaskRunLogMethod · 0.80

Calls 9

GetDBMethod · 0.95
QFunction · 0.92
SpaceMethod · 0.80
ToSQLMethod · 0.80
QueryContextMethod · 0.80
ScanMethod · 0.80
UnmarshalMethod · 0.80
CloseMethod · 0.65
NextMethod · 0.45

Tested by

no test coverage detected