Fix column name ambiguity in GetUserIssueStats() (#8347)
* Add test for FilterModeMention * Fix column name ambiguity * Fix fmt
This commit is contained in:
parent
cd13f273d1
commit
740a0c4dd4
|
@ -1661,14 +1661,14 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
case FilterModeAssign:
|
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").
|
Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
|
||||||
And("issue_assignees.assignee_id = ?", opts.UserID).
|
And("issue_assignees.assignee_id = ?", opts.UserID).
|
||||||
Count(new(Issue))
|
Count(new(Issue))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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").
|
Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
|
||||||
And("issue_assignees.assignee_id = ?", opts.UserID).
|
And("issue_assignees.assignee_id = ?", opts.UserID).
|
||||||
Count(new(Issue))
|
Count(new(Issue))
|
||||||
|
@ -1689,14 +1689,14 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
case FilterModeMention:
|
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).
|
Join("INNER", "issue_user", "issue.id = issue_user.issue_id and issue_user.is_mentioned = ?", true).
|
||||||
And("issue_user.uid = ?", opts.UserID).
|
And("issue_user.uid = ?", opts.UserID).
|
||||||
Count(new(Issue))
|
Count(new(Issue))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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).
|
Join("INNER", "issue_user", "issue.id = issue_user.issue_id and issue_user.is_mentioned = ?", true).
|
||||||
And("issue_user.uid = ?", opts.UserID).
|
And("issue_user.uid = ?", opts.UserID).
|
||||||
Count(new(Issue))
|
Count(new(Issue))
|
||||||
|
|
|
@ -279,6 +279,19 @@ func TestGetUserIssueStats(t *testing.T) {
|
||||||
ClosedCount: 2,
|
ClosedCount: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
UserIssueStatsOptions{
|
||||||
|
UserID: 1,
|
||||||
|
FilterMode: FilterModeMention,
|
||||||
|
},
|
||||||
|
IssueStats{
|
||||||
|
YourRepositoriesCount: 0,
|
||||||
|
AssignCount: 2,
|
||||||
|
CreateCount: 2,
|
||||||
|
OpenCount: 0,
|
||||||
|
ClosedCount: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
stats, err := GetUserIssueStats(test.Opts)
|
stats, err := GetUserIssueStats(test.Opts)
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
|
|
Loading…
Reference in New Issue