From 0a92da5719b212921ee1a7b3bf432bdfed8ddfa5 Mon Sep 17 00:00:00 2001 From: NorthRealm <155140859+NorthRealm@users.noreply.github.com> Date: Thu, 10 Jul 2025 02:12:07 +0800 Subject: [PATCH] sort --- services/mailer/mail_workflow_run.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/mailer/mail_workflow_run.go b/services/mailer/mail_workflow_run.go index d57784cfca..9cb1be4626 100644 --- a/services/mailer/mail_workflow_run.go +++ b/services/mailer/mail_workflow_run.go @@ -55,8 +55,13 @@ func sendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo_model.Rep } sort.SliceStable(jobs, func(i, j int) bool { si, sj := jobs[i].Status, jobs[j].Status - if si != sj || sj.IsSuccess() /* if not equal, then success is the max */ { - return true + /* + If both i and j are/are not success, leave it to si < sj. + If i is success and j is not, since the desired is j goes "smaller" and i goes "bigger", this func should return false. + If j is success and i is not, since the desired is i goes "smaller" and j goes "bigger", this func should return true. + */ + if si.IsSuccess() != sj.IsSuccess() { + return !si.IsSuccess() } return si < sj })