Things work together

This commit is contained in:
Gregory Eremin 2015-03-08 22:16:27 +07:00
parent 132a726744
commit 8d45e846ff
3 changed files with 36 additions and 16 deletions

View File

@ -94,17 +94,33 @@ var TeamStats = React.createClass({
}); });
var UserStats = React.createClass({ var UserStats = React.createClass({
mixins: [Router.Navigation, Router.State],
render: function(){ render: function(){
var topRepos = "/api/stat/users/top"+
"?org="+ this.getParams().org +
"&author="+ this.getParams().user +
"&item=repo",
repoURL = "/app/"+ this.getParams().org +"/repos/";
return ( return (
<section className="content">User stats!</section> <section className="content">
<BarChart api={topRepos} link={repoURL}/>
</section>
); );
} }
}); });
var RepoStats = React.createClass({ var RepoStats = React.createClass({
mixins: [Router.Navigation, Router.State],
render: function(){ render: function(){
var topAuthors = "/api/stat/repos/top"+
"?org="+ this.getParams().org +
"&repo="+ this.getParams().repo +
"&item=author",
userURL = "/app/"+ this.getParams().org +"/users/";
return ( return (
<section className="content">Repo Stats!</section> <section className="content">
<BarChart api={topAuthors} link={userURL}/>
</section>
); );
} }
}); });

View File

@ -105,6 +105,7 @@ select
from contribs c from contribs c
where where
c.owner = :org and c.owner = :org and
c.author = :author and
c.week >= :from and c.week >= :from and
c.week <= :to c.week <= :to
group by item group by item
@ -119,6 +120,7 @@ select
from contribs c from contribs c
where where
c.owner = :org and c.owner = :org and
c.author = :author and
c.week >= :from and c.week >= :from and
c.week <= :to c.week <= :to
group by item group by item
@ -126,7 +128,7 @@ order by week, commits desc`
const repoTopQuery = ` const repoTopQuery = `
select select
%s as item, c.author as item,
sum(c.commits) as commits, sum(c.commits) as commits,
sum(c.additions) - sum(c.deletions) as delta sum(c.additions) - sum(c.deletions) as delta
from contribs c from contribs c
@ -179,7 +181,7 @@ func StatOrgActivity(p map[string]interface{}) (res []StatPoint) {
func StatTeamTop(p map[string]interface{}) (res []StatItem) { func StatTeamTop(p map[string]interface{}) (res []StatItem) {
defer measure("StatTeamTop", time.Now()) defer measure("StatTeamTop", time.Now())
mustSelectN(&res, fmt.Sprintf(teamTopQuery, p["item"], p["sort"]), p) mustSelectN(&res, fmt.Sprintf(teamTopQuery, p["item"]), p)
return return
} }

View File

@ -21,7 +21,8 @@ type (
statRequest struct { statRequest struct {
Org string `structs:"org"` Org string `structs:"org"`
Team string `structs:"team"` Team string `structs:"team"`
User string `structs:"user"` Author string `structs:"author"`
Repo string `structs:"repo"`
From int64 `structs:"from"` From int64 `structs:"from"`
To int64 `structs:"to"` To int64 `structs:"to"`
Item string `structs:"item"` Item string `structs:"item"`
@ -86,7 +87,8 @@ func parseStatRequest(r *http.Request) *statRequest {
return &statRequest{ return &statRequest{
Org: r.FormValue("org"), Org: r.FormValue("org"),
Team: r.FormValue("team"), Team: r.FormValue("team"),
User: r.FormValue("user"), Author: r.FormValue("author"),
Repo: r.FormValue("repo"),
From: from, From: from,
To: to, To: to,
Item: item, Item: item,