Skip to content

Commit e69da2c

Browse files
authored
Fix bug on activities (#33008)
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)
1 parent e435b19 commit e69da2c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

models/activities/repo_activity.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/modules/git"
1717
"code.gitea.io/gitea/modules/gitrepo"
1818

19+
"xorm.io/builder"
1920
"xorm.io/xorm"
2021
)
2122

@@ -337,8 +338,10 @@ func newlyCreatedIssues(ctx context.Context, repoID int64, fromTime time.Time) *
337338
func activeIssues(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session {
338339
sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID).
339340
And("issue.is_pull = ?", false).
340-
And("issue.created_unix >= ?", fromTime.Unix()).
341-
Or("issue.closed_unix >= ?", fromTime.Unix())
341+
And(builder.Or(
342+
builder.Gte{"issue.created_unix": fromTime.Unix()},
343+
builder.Gte{"issue.closed_unix": fromTime.Unix()},
344+
))
342345

343346
return sess
344347
}

0 commit comments

Comments
 (0)