forked from Gitlink/gitea-1120-rc1
add: contributor email
This commit is contained in:
parent
c9c2aac882
commit
efb91bdc6e
|
@ -9,52 +9,51 @@ type GetContributorsOptionsExt struct {
|
|||
}
|
||||
|
||||
type ContributorsDto struct {
|
||||
Contributions int64 `json:"contributions"`
|
||||
ID int64 `json:"id"`
|
||||
Contributions int64 `json:"contributions"`
|
||||
ID int64 `json:"id"`
|
||||
Login string `json:"login"`
|
||||
Email string `json:"email"`
|
||||
//Type string `json:"type"`
|
||||
}
|
||||
|
||||
func GetContributors(opt GetContributorsOptionsExt) (interface{}, error) {
|
||||
sql:=
|
||||
sql :=
|
||||
`select a.act_user_id as id ,
|
||||
u.name as login,
|
||||
u.email as email,
|
||||
count(act_user_id) as contributions
|
||||
from action a
|
||||
left join user u on a.act_user_id=u.id
|
||||
where repo_id=? and user_id=?
|
||||
group by repo_id,act_user_id `
|
||||
|
||||
result:=make([]ContributorsDto,0,0)
|
||||
err:=x.SQL(sql,opt.RepoId,opt.UserId).Find(&result)
|
||||
return result,err
|
||||
result := make([]ContributorsDto, 0, 0)
|
||||
err := x.SQL(sql, opt.RepoId, opt.UserId).Find(&result)
|
||||
return result, err
|
||||
}
|
||||
|
||||
|
||||
|
||||
type GetGetActivityOptions struct {
|
||||
FromDateUnix int64 `json:"-"`
|
||||
ToDateUnix int64 `json:"-"`
|
||||
FromDate string `json:"from_date"`
|
||||
ToDate string `json:"to_date"`
|
||||
Top int64 `json:"-"`
|
||||
FromDateUnix int64 `json:"-"`
|
||||
ToDateUnix int64 `json:"-"`
|
||||
FromDate string `json:"from_date"`
|
||||
ToDate string `json:"to_date"`
|
||||
Top int64 `json:"-"`
|
||||
}
|
||||
|
||||
|
||||
type PlatformDTO struct {
|
||||
Id int64 `json:"-"`
|
||||
Name string `json:"-"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
Id int64 `json:"-"`
|
||||
Name string `json:"-"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
}
|
||||
|
||||
//平台所需数据;
|
||||
func GetActivity(opt *GetGetActivityOptions) (interface{}, error) {
|
||||
//sql:=
|
||||
//sql:=
|
||||
// `select a.id,a.name,ifNull(b.active_count,0) as active_count,t.total_count
|
||||
// from ( select 11 as id ,'PullRequest' name union
|
||||
// select 5 as id, 'Commit' name
|
||||
// ) a
|
||||
// from ( select 11 as id ,'PullRequest' name union
|
||||
// select 5 as id, 'Commit' name
|
||||
// ) a
|
||||
// left join (
|
||||
// select op_type, count(op_type) as active_count
|
||||
// from action a
|
||||
|
@ -70,7 +69,7 @@ func GetActivity(opt *GetGetActivityOptions) (interface{}, error) {
|
|||
// ) t on a.id=t.op_type
|
||||
//`
|
||||
|
||||
sql:=`select a.id,a.name,ifNull(b.active_count,0) as active_count,b.total_count
|
||||
sql := `select a.id,a.name,ifNull(b.active_count,0) as active_count,b.total_count
|
||||
from ( select 11 as id ,'PullRequest' name
|
||||
union
|
||||
select 5 as id, 'Commit' name
|
||||
|
@ -85,33 +84,31 @@ func GetActivity(opt *GetGetActivityOptions) (interface{}, error) {
|
|||
group by a.op_type
|
||||
) b on a.id=b.op_type`
|
||||
|
||||
datalist:=make([]PlatformDTO,0,0)
|
||||
err:=x.SQL(sql,opt.FromDateUnix,opt.ToDateUnix).Find(&datalist)
|
||||
if err !=nil {
|
||||
return nil ,err
|
||||
datalist := make([]PlatformDTO, 0, 0)
|
||||
err := x.SQL(sql, opt.FromDateUnix, opt.ToDateUnix).Find(&datalist)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
convertMap:=make(map[string]interface{})
|
||||
for i:=0;i<=len(datalist)-1;i++{
|
||||
convertMap[strings.ToLower(datalist[i].Name)]=datalist[i]
|
||||
convertMap := make(map[string]interface{})
|
||||
for i := 0; i <= len(datalist)-1; i++ {
|
||||
convertMap[strings.ToLower(datalist[i].Name)] = datalist[i]
|
||||
}
|
||||
//convertMap["param"]=opt
|
||||
|
||||
return convertMap,err
|
||||
return convertMap, err
|
||||
}
|
||||
|
||||
|
||||
type ProjectDTO struct {
|
||||
Id int64 `json:"-"`
|
||||
Name string `json:"name"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
Id int64 `json:"-"`
|
||||
Name string `json:"name"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
}
|
||||
|
||||
|
||||
//项目所需数据-按项目统计 top 5
|
||||
func GetActivityProject(opt *GetGetActivityOptions) (interface{}, error) {
|
||||
sql:=
|
||||
sql :=
|
||||
`select repo_id as id,r.name,
|
||||
count(op_type) as total_count,
|
||||
sum(case when a.created_unix>=? and a.created_unix<=?
|
||||
|
@ -125,15 +122,14 @@ func GetActivityProject(opt *GetGetActivityOptions) (interface{}, error) {
|
|||
limit ?
|
||||
`
|
||||
|
||||
datalist:=make([]ProjectDTO,0,0)
|
||||
err:=x.SQL(sql,opt.FromDateUnix,opt.ToDateUnix,opt.Top).Find(&datalist)
|
||||
return datalist,err
|
||||
datalist := make([]ProjectDTO, 0, 0)
|
||||
err := x.SQL(sql, opt.FromDateUnix, opt.ToDateUnix, opt.Top).Find(&datalist)
|
||||
return datalist, err
|
||||
}
|
||||
|
||||
|
||||
//项目所需数据-按开发者统计 top 5
|
||||
func GetActivityDevelop(opt *GetGetActivityOptions) (interface{}, error) {
|
||||
sql:=
|
||||
sql :=
|
||||
`select u.name as develop_name,
|
||||
count(op_type) as total_count,
|
||||
sum(case when (a.created_unix>=? and a.created_unix<=?) then 1 else 0 end ) as active_count
|
||||
|
@ -144,14 +140,13 @@ func GetActivityDevelop(opt *GetGetActivityOptions) (interface{}, error) {
|
|||
order by total_count desc
|
||||
limit ? `
|
||||
|
||||
datalist:=make([]DevelopDTO,0,0)
|
||||
err:=x.SQL(sql,opt.FromDateUnix,opt.ToDateUnix,opt.Top).Find(&datalist)
|
||||
return datalist,err
|
||||
datalist := make([]DevelopDTO, 0, 0)
|
||||
err := x.SQL(sql, opt.FromDateUnix, opt.ToDateUnix, opt.Top).Find(&datalist)
|
||||
return datalist, err
|
||||
}
|
||||
|
||||
type DevelopDTO struct {
|
||||
DevelopName string `json:"develop_name"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
|
||||
TotalCount int64 `json:"total_count"`
|
||||
ActiveCount int64 `json:"active_count"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue