Skip to content

Commit

Permalink
feat: add bcs-task mysql store add createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
ifooth committed Oct 24, 2024
1 parent 86c8306 commit f7a5f1c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bcs-common/common/task/stores/iface/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type ListOption struct {
CurrentStep string
Status string
Creator string
StartGte *time.Time // StartGte start time greater or equal to
StartLte *time.Time // StartLte start time less or equal to
CreatedGte *time.Time // CreatedGte create time greater or equal to
CreatedLte *time.Time // CreatedLte create time less or equal to
Sort map[string]int // Sort map for sort list results
Offset int64 // Offset offset for list results
Limit int64 // Limit limit for list results
Expand Down
3 changes: 2 additions & 1 deletion bcs-common/common/task/stores/mysql/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ func toTask(task *TaskRecord, steps []*StepRecord) *types.Task {
End: task.End,
ExecutionTime: task.ExecutionTime,
MaxExecutionSeconds: task.MaxExecutionSeconds,
Creator: task.Creator,
CreatedAt: task.CreatedAt,
LastUpdate: task.UpdatedAt,
Creator: task.Creator,
Updater: task.Updater,
}

Expand Down
8 changes: 4 additions & 4 deletions bcs-common/common/task/stores/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ func (s *mysqlStore) ListTask(ctx context.Context, opt *iface.ListOption) (*ifac
})

// mysql store 使用创建时间过滤
if opt.StartGte != nil {
tx = tx.Where("created_at >= ?", opt.StartGte)
if opt.CreatedGte != nil {
tx = tx.Where("created_at >= ?", opt.CreatedGte)
}
if opt.StartLte != nil {
tx = tx.Where("created_at <= ?", opt.StartLte)
if opt.CreatedLte != nil {
tx = tx.Where("created_at <= ?", opt.CreatedLte)
}

// 只使用id排序
Expand Down
1 change: 1 addition & 0 deletions bcs-common/common/task/types/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type Task struct {
Updater string `json:"updater"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
CreatedAt time.Time `json:"createdAt"`
LastUpdate time.Time `json:"lastUpdate"`
}

Expand Down

0 comments on commit f7a5f1c

Please sign in to comment.