forked from Gitlink/gitea_hat
28 lines
654 B
Go
28 lines
654 B
Go
package models
|
|
|
|
import (
|
|
"code.gitea.io/gitea/models/db"
|
|
)
|
|
|
|
type Contributor struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
Contributions int64 `json:"contributions"`
|
|
}
|
|
|
|
func GetContributors(repoID, userID int64) (result []Contributor, err error) {
|
|
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 `
|
|
|
|
err = db.GetEngine(db.DefaultContext).SQL(sql, repoID, userID).Find(&result)
|
|
return
|
|
}
|