@@ -55,17 +55,15 @@ func CreateCommitStatusForRunJobs(ctx context.Context, run *actions_model.Action
5555 }
5656}
5757
58- func GetRunsAndJobsFromCommitStatuses (ctx context.Context , statuses []* git_model.CommitStatus ) ([]* actions_model.ActionRun , []* actions_model.ActionRunJob , error ) {
59- jobMap := make (map [int64 ]* actions_model.ActionRunJob )
58+ func GetRunsFromCommitStatuses (ctx context.Context , statuses []* git_model.CommitStatus ) ([]* actions_model.ActionRun , error ) {
6059 runMap := make (map [int64 ]* actions_model.ActionRun )
61- jobsMap := make (map [int64 ][]* actions_model.ActionRunJob )
6260 for _ , status := range statuses {
6361 if ! status .CreatedByGiteaActions (ctx ) {
6462 continue
6563 }
66- runIndex , jobIndex , err := getActionRunAndJobIndexFromCommitStatus (status )
64+ runIndex , _ , err := getActionRunAndJobIndexFromCommitStatus (status )
6765 if err != nil {
68- return nil , nil , fmt .Errorf ("getActionRunAndJobIndexFromCommitStatus: %w" , err )
66+ return nil , fmt .Errorf ("getActionRunAndJobIndexFromCommitStatus: %w" , err )
6967 }
7068 run , ok := runMap [runIndex ]
7169 if ! ok {
@@ -75,33 +73,16 @@ func GetRunsAndJobsFromCommitStatuses(ctx context.Context, statuses []*git_model
7573 // the run may be deleted manually, just skip it
7674 continue
7775 }
78- return nil , nil , fmt .Errorf ("GetRunByIndex: %w" , err )
76+ return nil , fmt .Errorf ("GetRunByIndex: %w" , err )
7977 }
8078 runMap [runIndex ] = run
8179 }
82- jobs , ok := jobsMap [runIndex ]
83- if ! ok {
84- jobs , err = actions_model .GetRunJobsByRunID (ctx , run .ID )
85- if err != nil {
86- return nil , nil , fmt .Errorf ("GetRunJobByIndex: %w" , err )
87- }
88- jobsMap [runIndex ] = jobs
89- }
90- if jobIndex < 0 || jobIndex >= int64 (len (jobs )) {
91- return nil , nil , fmt .Errorf ("job index %d out of range for run %d" , jobIndex , runIndex )
92- }
93- job := jobs [jobIndex ]
94- jobMap [job .ID ] = job
9580 }
9681 runs := make ([]* actions_model.ActionRun , 0 , len (runMap ))
9782 for _ , run := range runMap {
9883 runs = append (runs , run )
9984 }
100- jobs := make ([]* actions_model.ActionRunJob , 0 , len (jobMap ))
101- for _ , job := range jobMap {
102- jobs = append (jobs , job )
103- }
104- return runs , jobs , nil
85+ return runs , nil
10586}
10687
10788func getActionRunAndJobIndexFromCommitStatus (status * git_model.CommitStatus ) (int64 , int64 , error ) {
0 commit comments