Skip to content

Commit

Permalink
Fix bug on activities (#33008)
Browse files Browse the repository at this point in the history
A repository with no issue will display a random number on activities
page. This is caused by wrong usage of `And` and `Or`.

![9cdbbf81d50aa5d9bd16604e0dab5eb0](https://github.com/user-attachments/assets/828cebdc-bd35-4716-a58c-c1b43ddf8bf0)
  • Loading branch information
lunny authored Dec 28, 2024
1 parent e435b19 commit e69da2c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions models/activities/repo_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"

"xorm.io/builder"
"xorm.io/xorm"
)

Expand Down Expand Up @@ -337,8 +338,10 @@ func newlyCreatedIssues(ctx context.Context, repoID int64, fromTime time.Time) *
func activeIssues(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session {
sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID).
And("issue.is_pull = ?", false).
And("issue.created_unix >= ?", fromTime.Unix()).
Or("issue.closed_unix >= ?", fromTime.Unix())
And(builder.Or(
builder.Gte{"issue.created_unix": fromTime.Unix()},
builder.Gte{"issue.closed_unix": fromTime.Unix()},
))

return sess
}
Expand Down

0 comments on commit e69da2c

Please sign in to comment.