giteabot backport / giteabot (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
cache-seeder / gobuild (push) Canceled after 0s
cache-seeder / lint (bindata, lint-backend) (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
Includes direct password setup links in registration emails. Assisted-by: Codex:GPT-5
25 lines
728 B
Go
25 lines
728 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_26
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gitea.dev/models/db"
|
|
)
|
|
|
|
func FixClosedMilestoneCompleteness(x db.EngineMigration) 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
|
|
}
|