aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-12-27 20:04:07 -0800
committerGitHub <noreply@github.com>2024-12-28 04:04:07 +0000
commite69da2cd07da8637d8fa5802b78882598a545299 (patch)
tree4930fbc8f30e455e97d2ffbea2c5b428f8f928e2
parente435b1900a00dd98d65aa1f7668fe41e4df83044 (diff)
downloadgitea-e69da2cd07da8637d8fa5802b78882598a545299.tar.gz
gitea-e69da2cd07da8637d8fa5802b78882598a545299.zip
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)
-rw-r--r--models/activities/repo_activity.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/models/activities/repo_activity.go b/models/activities/repo_activity.go
index 3ffad035b7..3ccdbd47d3 100644
--- a/models/activities/repo_activity.go
+++ b/models/activities/repo_activity.go
@@ -16,6 +16,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
+ "xorm.io/builder"
"xorm.io/xorm"
)
@@ -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
}