Skip to content

Commit 489a660

Browse files
committed
fix-stats-count
1 parent e6cae8a commit 489a660

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

models/issue_milestone.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -543,28 +543,23 @@ func GetMilestonesByRepoIDs(repoIDs []int64, page int, isClosed bool, sortType s
543543
return miles, sess.Find(&miles)
544544
}
545545

546-
// UserMilestoneStats represents milestone statistic information.
547-
type UserMilestoneStats struct {
546+
// MilestonesStats represents milestone statistic information.
547+
type MilestonesStats struct {
548548
OpenCount, ClosedCount int64
549549
}
550550

551-
// GetUserMilestoneStats returns milestone statistic information for dashboard by given conditions.
552-
func GetUserMilestoneStats(userID int64, repoID int64, userRepoIDs []int64) (*UserMilestoneStats, error) {
551+
// GetMilestonesStats returns milestone statistic information for dashboard by given conditions.
552+
func GetMilestonesStats(userRepoIDs []int64) (*MilestonesStats, error) {
553553
var err error
554-
stats := &UserMilestoneStats{}
554+
stats := &MilestonesStats{}
555555

556-
cond := builder.NewCond()
557-
if repoID > 0 {
558-
cond = cond.And(builder.Eq{"repo_id": repoID})
559-
}
560-
561-
stats.OpenCount, err = x.Where(cond).And("is_closed = ?", false).
556+
stats.OpenCount, err = x.Where("is_closed = ?", false).
562557
And(builder.In("repo_id", userRepoIDs)).
563558
Count(new(Milestone))
564559
if err != nil {
565560
return nil, err
566561
}
567-
stats.ClosedCount, err = x.Where(cond).And("is_closed = ?", true).
562+
stats.ClosedCount, err = x.Where("is_closed = ?", true).
568563
And(builder.In("repo_id", userRepoIDs)).
569564
Count(new(Milestone))
570565
if err != nil {

routers/user/home.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ func Milestones(ctx *context.Context) {
285285
}
286286
}
287287

288-
milestoneStats, err := models.GetUserMilestoneStats(ctxUser.ID, repoID, userRepoIDs)
288+
milestoneStats, err := models.GetMilestonesStats(userRepoIDs)
289289
if err != nil {
290-
ctx.ServerError("GetUserMilestoneStats", err)
290+
ctx.ServerError("GetMilestoneStats", err)
291291
return
292292
}
293293

templates/user/dashboard/milestones.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="ui stackable grid">
66
<div class="four wide column">
77
<div class="ui secondary vertical filter menu">
8-
<a class="item" href="{{.Link}}?type=your_repositories&repo={{.RepoID}}&sort={{$.SortType}}&state={{.State}}">
8+
<a class="item" href="{{.Link}}?type=your_repositories&sort={{$.SortType}}&state={{.State}}">
99
{{.i18n.Tr "home.issues.in_your_repos"}}
1010
<strong class="ui right">{{.Total}}</strong>
1111
</a>

0 commit comments

Comments
 (0)