@@ -72,39 +72,50 @@ type FindRunOptions struct {
7272 TriggerEvent webhook_module.HookEventType
7373 Approved bool // not util.OptionalBool, it works only when it's true
7474 Status []Status
75+ CommitSHA string
7576}
7677
7778func (opts FindRunOptions ) ToConds () builder.Cond {
7879 cond := builder .NewCond ()
7980 if opts .RepoID > 0 {
80- cond = cond .And (builder.Eq {"repo_id" : opts .RepoID })
81- }
82- if opts .OwnerID > 0 {
83- cond = cond .And (builder.Eq {"owner_id" : opts .OwnerID })
81+ cond = cond .And (builder.Eq {"`action_run`.repo_id" : opts .RepoID })
8482 }
8583 if opts .WorkflowID != "" {
86- cond = cond .And (builder.Eq {"workflow_id" : opts .WorkflowID })
84+ cond = cond .And (builder.Eq {"`action_run`. workflow_id" : opts .WorkflowID })
8785 }
8886 if opts .TriggerUserID > 0 {
89- cond = cond .And (builder.Eq {"trigger_user_id" : opts .TriggerUserID })
87+ cond = cond .And (builder.Eq {"`action_run`. trigger_user_id" : opts .TriggerUserID })
9088 }
9189 if opts .Approved {
92- cond = cond .And (builder.Gt {"approved_by" : 0 })
90+ cond = cond .And (builder.Gt {"`action_run`. approved_by" : 0 })
9391 }
9492 if len (opts .Status ) > 0 {
95- cond = cond .And (builder .In ("status" , opts .Status ))
93+ cond = cond .And (builder .In ("`action_run`. status" , opts .Status ))
9694 }
9795 if opts .Ref != "" {
98- cond = cond .And (builder.Eq {"ref" : opts .Ref })
96+ cond = cond .And (builder.Eq {"`action_run`. ref" : opts .Ref })
9997 }
10098 if opts .TriggerEvent != "" {
101- cond = cond .And (builder.Eq {"trigger_event" : opts .TriggerEvent })
99+ cond = cond .And (builder.Eq {"`action_run`.trigger_event" : opts .TriggerEvent })
100+ }
101+ if opts .CommitSHA != "" {
102+ cond = cond .And (builder.Eq {"`action_run`.commit_sha" : opts .CommitSHA })
102103 }
103104 return cond
104105}
105106
107+ func (opts FindRunOptions ) ToJoins () []db.JoinFunc {
108+ if opts .OwnerID > 0 {
109+ return []db.JoinFunc {func (sess db.Engine ) error {
110+ sess .Join ("INNER" , "repository" , "repository.id = repo_id AND repository.owner_id = ?" , opts .OwnerID )
111+ return nil
112+ }}
113+ }
114+ return nil
115+ }
116+
106117func (opts FindRunOptions ) ToOrders () string {
107- return "`id` DESC"
118+ return "`action_run`.` id` DESC"
108119}
109120
110121type StatusInfo struct {
0 commit comments