0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-12-21 16:44:27 +01:00
Scion 495fee4555
Closed milestones with no issues now show as 100% completed (#36220)
Closed milestones with 0 issues currently display as having 0%
completion. This makes sense if the milestone is still open, but if the
milestone is closed it seems like that it should show 100% completeness
instead.

Before:
<img width="1708" height="252" alt="image"
src="https://github.com/user-attachments/assets/0b58c78f-0609-44ee-8d58-bd67534c6164"
/>
After:
<img width="1716" height="263" alt="image"
src="https://github.com/user-attachments/assets/3fb0044f-d76c-4888-9d60-640f2ca5fec6"
/>
2025-12-20 16:16:20 +00:00

25 lines
715 B
Go

// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_26
import (
"fmt"
"xorm.io/xorm"
)
func FixClosedMilestoneCompleteness(x *xorm.Engine) error {
// Update all milestones to recalculate completeness with the new logic:
// - Closed milestones with 0 issues should show 100%
// - All other milestones should calculate based on closed/total ratio
_, err := x.Exec("UPDATE `milestone` SET completeness=(CASE WHEN is_closed = ? AND num_issues = 0 THEN 100 ELSE 100*num_closed_issues/(CASE WHEN num_issues > 0 THEN num_issues ELSE 1 END) END)",
true,
)
if err != nil {
return fmt.Errorf("error updating milestone completeness: %w", err)
}
return nil
}