@ -1004,17 +1004,17 @@ func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*Issue
}
}
// GetIssueUserPairsByMode returns issue-user pairs by given repository and user.
// GetIssueUserPairsByMode returns issue-user pairs by given repository and user.
func GetIssueUserPairsByMode ( uid , rid int64 , isClosed bool , page , filterMod e int ) ( [ ] * IssueUser , error ) {
func GetIssueUserPairsByMode ( userID , repoID int64 , filterMode FilterMode , isClosed bool , pag e int ) ( [ ] * IssueUser , error ) {
ius := make ( [ ] * IssueUser , 0 , 10 )
ius := make ( [ ] * IssueUser , 0 , 10 )
sess := x . Limit ( 20 , ( page - 1 ) * 20 ) . Where ( "uid=?" , uid ) . And ( "is_closed=?" , isClosed )
sess := x . Limit ( 20 , ( page - 1 ) * 20 ) . Where ( "uid=?" , userID ) . And ( "is_closed=?" , isClosed )
if rid > 0 {
if repoID > 0 {
sess . And ( "repo_id=?" , rid )
sess . And ( "repo_id=?" , repoID )
}
}
switch filterMode {
switch filterMode {
case FM_ASSIGN :
case FILTER_ MODE _ASSIGN :
sess . And ( "is_assigned=?" , true )
sess . And ( "is_assigned=?" , true )
case FM_CREATE :
case FILTER_ MODE _CREATE :
sess . And ( "is_poster=?" , true )
sess . And ( "is_poster=?" , true )
default :
default :
return ius , nil
return ius , nil
@ -1069,18 +1069,19 @@ func updateIssueMentions(e Engine, issueID int64, mentions []string) error {
// IssueStats represents issue statistic information.
// IssueStats represents issue statistic information.
type IssueStats struct {
type IssueStats struct {
OpenCount , ClosedCount int64
OpenCount , ClosedCount int64
YourRepositories Count int64
YourReposCount int64
AssignCount int64
AssignCount int64
CreateCount int64
CreateCount int64
MentionCount int64
MentionCount int64
}
}
// Filter modes.
type FilterMode string
const (
const (
FM_YOUR_REPOSITORIES = iota
FILTER_MODE_YOUR_REPOS FilterMode = "your_repositories"
FM_ASSIGN
FILTER_ MODE _ASSIGN FilterMode = "assigned"
FM_CREATE
FILTER_ MODE _CREATE FilterMode = "created_by"
FM_MENTION
FILTER_ MODE _MENTION FilterMode = "mentioned"
)
)
func parseCountResult ( results [ ] map [ string ] [ ] byte ) int64 {
func parseCountResult ( results [ ] map [ string ] [ ] byte ) int64 {
@ -1099,7 +1100,7 @@ type IssueStatsOptions struct {
Labels string
Labels string
MilestoneID int64
MilestoneID int64
AssigneeID int64
AssigneeID int64
FilterMode int
FilterMode FilterMode
IsPull bool
IsPull bool
}
}
@ -1129,7 +1130,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
}
}
switch opts . FilterMode {
switch opts . FilterMode {
case FM_YOUR_REPOSITORIE S , FM_ASSIGN :
case FILTER_ MODE _YOUR_REPOS , FILTER_ MODE _ASSIGN :
stats . OpenCount , _ = countSession ( opts ) .
stats . OpenCount , _ = countSession ( opts ) .
And ( "is_closed = ?" , false ) .
And ( "is_closed = ?" , false ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
@ -1137,7 +1138,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
stats . ClosedCount , _ = countSession ( opts ) .
stats . ClosedCount , _ = countSession ( opts ) .
And ( "is_closed = ?" , true ) .
And ( "is_closed = ?" , true ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
case FM_CREATE :
case FILTER_ MODE _CREATE :
stats . OpenCount , _ = countSession ( opts ) .
stats . OpenCount , _ = countSession ( opts ) .
And ( "poster_id = ?" , opts . UserID ) .
And ( "poster_id = ?" , opts . UserID ) .
And ( "is_closed = ?" , false ) .
And ( "is_closed = ?" , false ) .
@ -1147,7 +1148,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
And ( "poster_id = ?" , opts . UserID ) .
And ( "poster_id = ?" , opts . UserID ) .
And ( "is_closed = ?" , true ) .
And ( "is_closed = ?" , true ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
case FM_MENTION :
case FILTER_ MODE _MENTION :
stats . OpenCount , _ = countSession ( opts ) .
stats . OpenCount , _ = countSession ( opts ) .
Join ( "INNER" , "issue_user" , "issue.id = issue_user.issue_id" ) .
Join ( "INNER" , "issue_user" , "issue.id = issue_user.issue_id" ) .
And ( "issue_user.uid = ?" , opts . UserID ) .
And ( "issue_user.uid = ?" , opts . UserID ) .
@ -1166,7 +1167,7 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats {
}
}
// GetUserIssueStats returns issue statistic information for dashboard by given conditions.
// GetUserIssueStats returns issue statistic information for dashboard by given conditions.
func GetUserIssueStats ( repoID , uid int64 , repoIDs [ ] int64 , filterMode int , isPull bool ) * IssueStats {
func GetUserIssueStats ( repoID , userID int64 , repoIDs [ ] int64 , filterMode FilterMode , isPull bool ) * IssueStats {
stats := & IssueStats { }
stats := & IssueStats { }
countSession := func ( isClosed , isPull bool , repoID int64 , repoIDs [ ] int64 ) * xorm . Session {
countSession := func ( isClosed , isPull bool , repoID int64 , repoIDs [ ] int64 ) * xorm . Session {
@ -1182,35 +1183,35 @@ func GetUserIssueStats(repoID, uid int64, repoIDs []int64, filterMode int, isPul
}
}
stats . AssignCount , _ = countSession ( false , isPull , repoID , nil ) .
stats . AssignCount , _ = countSession ( false , isPull , repoID , nil ) .
And ( "assignee_id = ?" , uid ) .
And ( "assignee_id = ?" , userID ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
stats . CreateCount , _ = countSession ( false , isPull , repoID , nil ) .
stats . CreateCount , _ = countSession ( false , isPull , repoID , nil ) .
And ( "poster_id = ?" , uid ) .
And ( "poster_id = ?" , userID ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
stats . YourRepositories Count , _ = countSession ( false , isPull , repoID , repoIDs ) .
stats . YourReposCount , _ = countSession ( false , isPull , repoID , repoIDs ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
switch filterMode {
switch filterMode {
case FM_YOUR_REPOSITORIE S :
case FILTER_ MODE _YOUR_REPOS :
stats . OpenCount , _ = countSession ( false , isPull , repoID , repoIDs ) .
stats . OpenCount , _ = countSession ( false , isPull , repoID , repoIDs ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
stats . ClosedCount , _ = countSession ( true , isPull , repoID , repoIDs ) .
stats . ClosedCount , _ = countSession ( true , isPull , repoID , repoIDs ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
case FM_ASSIGN :
case FILTER_ MODE _ASSIGN :
stats . OpenCount , _ = countSession ( false , isPull , repoID , nil ) .
stats . OpenCount , _ = countSession ( false , isPull , repoID , nil ) .
And ( "assignee_id = ?" , uid ) .
And ( "assignee_id = ?" , userID ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
stats . ClosedCount , _ = countSession ( true , isPull , repoID , nil ) .
stats . ClosedCount , _ = countSession ( true , isPull , repoID , nil ) .
And ( "assignee_id = ?" , uid ) .
And ( "assignee_id = ?" , userID ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
case FM_CREATE :
case FILTER_ MODE _CREATE :
stats . OpenCount , _ = countSession ( false , isPull , repoID , nil ) .
stats . OpenCount , _ = countSession ( false , isPull , repoID , nil ) .
And ( "poster_id = ?" , uid ) .
And ( "poster_id = ?" , userID ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
stats . ClosedCount , _ = countSession ( true , isPull , repoID , nil ) .
stats . ClosedCount , _ = countSession ( true , isPull , repoID , nil ) .
And ( "poster_id = ?" , uid ) .
And ( "poster_id = ?" , userID ) .
Count ( new ( Issue ) )
Count ( new ( Issue ) )
}
}
@ -1218,7 +1219,7 @@ func GetUserIssueStats(repoID, uid int64, repoIDs []int64, filterMode int, isPul
}
}
// GetRepoIssueStats returns number of open and closed repository issues by given filter mode.
// GetRepoIssueStats returns number of open and closed repository issues by given filter mode.
func GetRepoIssueStats ( repoID , uid int64 , filterMode int , isPull bool ) ( numOpen int64 , numClosed int64 ) {
func GetRepoIssueStats ( repoID , userID int64 , filterMode FilterMode , isPull bool ) ( numOpen int64 , numClosed int64 ) {
countSession := func ( isClosed , isPull bool , repoID int64 ) * xorm . Session {
countSession := func ( isClosed , isPull bool , repoID int64 ) * xorm . Session {
sess := x . Where ( "issue.repo_id = ?" , isClosed ) .
sess := x . Where ( "issue.repo_id = ?" , isClosed ) .
And ( "is_pull = ?" , isPull ) .
And ( "is_pull = ?" , isPull ) .
@ -1231,12 +1232,12 @@ func GetRepoIssueStats(repoID, uid int64, filterMode int, isPull bool) (numOpen
closedCountSession := countSession ( true , isPull , repoID )
closedCountSession := countSession ( true , isPull , repoID )
switch filterMode {
switch filterMode {
case FM_ASSIGN :
case FILTER_ MODE _ASSIGN :
openCountSession . And ( "assignee_id = ?" , uid )
openCountSession . And ( "assignee_id = ?" , userID )
closedCountSession . And ( "assignee_id = ?" , uid )
closedCountSession . And ( "assignee_id = ?" , userID )
case FM_CREATE :
case FILTER_ MODE _CREATE :
openCountSession . And ( "poster_id = ?" , uid )
openCountSession . And ( "poster_id = ?" , userID )
closedCountSession . And ( "poster_id = ?" , uid )
closedCountSession . And ( "poster_id = ?" , userID )
}
}
openResult , _ := openCountSession . Count ( new ( Issue ) )
openResult , _ := openCountSession . Count ( new ( Issue ) )