diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-10-02 21:03:18 -0300 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-10-03 08:03:18 +0800 |
commit | 740a0c4dd46a93ec6d35c44f57b677d99f267210 (patch) | |
tree | 1c2c179fd7a64fdfc879d5ef01a76576b17d59e3 /models | |
parent | cd13f273d1663ef5f1f506bf3824f79bc73656ff (diff) | |
download | gitea-740a0c4dd46a93ec6d35c44f57b677d99f267210.tar.gz gitea-740a0c4dd46a93ec6d35c44f57b677d99f267210.zip |
Fix column name ambiguity in GetUserIssueStats() (#8347)
* Add test for FilterModeMention
* Fix column name ambiguity
* Fix fmt
Diffstat (limited to 'models')
-rw-r--r-- | models/issue.go | 8 | ||||
-rw-r--r-- | models/issue_test.go | 13 |
2 files changed, 17 insertions, 4 deletions
diff --git a/models/issue.go b/models/issue.go index 09d443384b..9590bc04ff 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1661,14 +1661,14 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) { return nil, err } case FilterModeAssign: - stats.OpenCount, err = x.Where(cond).And("is_closed = ?", false). + stats.OpenCount, err = x.Where(cond).And("issue.is_closed = ?", false). Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id"). And("issue_assignees.assignee_id = ?", opts.UserID). Count(new(Issue)) if err != nil { return nil, err } - stats.ClosedCount, err = x.Where(cond).And("is_closed = ?", true). + stats.ClosedCount, err = x.Where(cond).And("issue.is_closed = ?", true). Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id"). And("issue_assignees.assignee_id = ?", opts.UserID). Count(new(Issue)) @@ -1689,14 +1689,14 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) { return nil, err } case FilterModeMention: - stats.OpenCount, err = x.Where(cond).And("is_closed = ?", false). + stats.OpenCount, err = x.Where(cond).And("issue.is_closed = ?", false). Join("INNER", "issue_user", "issue.id = issue_user.issue_id and issue_user.is_mentioned = ?", true). And("issue_user.uid = ?", opts.UserID). Count(new(Issue)) if err != nil { return nil, err } - stats.ClosedCount, err = x.Where(cond).And("is_closed = ?", true). + stats.ClosedCount, err = x.Where(cond).And("issue.is_closed = ?", true). Join("INNER", "issue_user", "issue.id = issue_user.issue_id and issue_user.is_mentioned = ?", true). And("issue_user.uid = ?", opts.UserID). Count(new(Issue)) diff --git a/models/issue_test.go b/models/issue_test.go index 317fc7bbc8..9cd9ff0ad9 100644 --- a/models/issue_test.go +++ b/models/issue_test.go @@ -279,6 +279,19 @@ func TestGetUserIssueStats(t *testing.T) { ClosedCount: 2, }, }, + { + UserIssueStatsOptions{ + UserID: 1, + FilterMode: FilterModeMention, + }, + IssueStats{ + YourRepositoriesCount: 0, + AssignCount: 2, + CreateCount: 2, + OpenCount: 0, + ClosedCount: 0, + }, + }, } { stats, err := GetUserIssueStats(test.Opts) if !assert.NoError(t, err) { |