All top & activity report apis
This commit is contained in:
@@ -25,7 +25,6 @@ type (
|
||||
From int64 `structs:"from"`
|
||||
To int64 `structs:"to"`
|
||||
Item string `structs:"item"`
|
||||
Sort string `structs:"sort"`
|
||||
}
|
||||
)
|
||||
|
||||
@@ -84,14 +83,6 @@ func parseStatRequest(r *http.Request) *statRequest {
|
||||
item = "c.repo"
|
||||
}
|
||||
|
||||
var sort string
|
||||
switch val := r.FormValue("sort"); val {
|
||||
case "commits", "delta":
|
||||
sort = val
|
||||
default:
|
||||
sort = "commits"
|
||||
}
|
||||
|
||||
return &statRequest{
|
||||
Org: r.FormValue("org"),
|
||||
Team: r.FormValue("team"),
|
||||
@@ -99,7 +90,6 @@ func parseStatRequest(r *http.Request) *statRequest {
|
||||
From: from,
|
||||
To: to,
|
||||
Item: item,
|
||||
Sort: sort,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ func init() {
|
||||
http.HandleFunc("/api/stat/orgs/activity", statOrgActivityHandler)
|
||||
http.HandleFunc("/api/stat/teams/top", statTeamTopHandler)
|
||||
http.HandleFunc("/api/stat/teams/activity", statTeamActivityHandler)
|
||||
http.HandleFunc("/api/stat/users/top", statUserTopHandler)
|
||||
http.HandleFunc("/api/stat/users/activity", statUserActivityHandler)
|
||||
http.HandleFunc("/api/stat/repos/top", statRepoTopHandler)
|
||||
http.HandleFunc("/api/stat/repos/activity", statRepoActivityHandler)
|
||||
}
|
||||
|
||||
func Start() {
|
||||
|
||||
@@ -30,3 +30,27 @@ func statTeamActivityHandler(w http.ResponseWriter, r *http.Request) {
|
||||
activity := db.StatTeamActivity(structs.Map(stat))
|
||||
req.respondWith(activity)
|
||||
}
|
||||
|
||||
func statUserTopHandler(w http.ResponseWriter, r *http.Request) {
|
||||
req, stat := parseRequest(w, r)
|
||||
top := db.StatUserTop(structs.Map(stat))
|
||||
req.respondWith(top)
|
||||
}
|
||||
|
||||
func statUserActivityHandler(w http.ResponseWriter, r *http.Request) {
|
||||
req, stat := parseRequest(w, r)
|
||||
activity := db.StatUserActivity(structs.Map(stat))
|
||||
req.respondWith(activity)
|
||||
}
|
||||
|
||||
func statRepoTopHandler(w http.ResponseWriter, r *http.Request) {
|
||||
req, stat := parseRequest(w, r)
|
||||
top := db.StatRepoTop(structs.Map(stat))
|
||||
req.respondWith(top)
|
||||
}
|
||||
|
||||
func statRepoActivityHandler(w http.ResponseWriter, r *http.Request) {
|
||||
req, stat := parseRequest(w, r)
|
||||
activity := db.StatRepoActivity(structs.Map(stat))
|
||||
req.respondWith(activity)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user