Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column name ambiguity in GetUserIssueStats() #8347

Merged
merged 22 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9dbabcd
Merge go-gitea/master into master
guillep2k Sep 14, 2019
889c619
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 14, 2019
d7c46c8
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 15, 2019
8eaacbf
Merge remote-tracking branch 'refs/remotes/origin/master'
guillep2k Sep 19, 2019
de5aa64
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 19, 2019
80c6f2b
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 20, 2019
ac40f7f
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 22, 2019
f6ac46b
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 23, 2019
b563158
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 25, 2019
6f55d1e
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 25, 2019
188e164
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 26, 2019
fd6fe8c
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 27, 2019
54624dd
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 29, 2019
e2a6388
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 30, 2019
b8d4abf
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Oct 2, 2019
d6538d8
Add test for FilterModeMention
guillep2k Oct 2, 2019
6d7ef8c
Fix column name ambiguity
guillep2k Oct 2, 2019
919ef1e
Fix fmt
guillep2k Oct 2, 2019
b7b707c
Merge branch 'master' into fix-8231
lunny Oct 2, 2019
6d22f54
Merge branch 'master' into fix-8231
lunny Oct 2, 2019
5ecdfc2
Merge branch 'master' into fix-8231
techknowlogick Oct 2, 2019
8211a73
Merge branch 'master' into fix-8231
guillep2k Oct 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1655,14 +1655,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))
Expand All @@ -1683,14 +1683,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))
Expand Down
13 changes: 13 additions & 0 deletions models/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down