1
0
Fork 0

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({
mixins: [Router.Navigation, Router.State],
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 (
<section className="content">User stats!</section>
<section className="content">
<BarChart api={topRepos} link={repoURL}/>
</section>
);
}
});
var RepoStats = React.createClass({
mixins: [Router.Navigation, Router.State],
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 (
<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
where
c.owner = :org and
c.author = :author and
c.week >= :from and
c.week <= :to
group by item
@ -119,6 +120,7 @@ select
from contribs c
where
c.owner = :org and
c.author = :author and
c.week >= :from and
c.week <= :to
group by item
@ -126,7 +128,7 @@ order by week, commits desc`
const repoTopQuery = `
select
%s as item,
c.author as item,
sum(c.commits) as commits,
sum(c.additions) - sum(c.deletions) as delta
from contribs c
@ -179,7 +181,7 @@ func StatOrgActivity(p map[string]interface{}) (res []StatPoint) {
func StatTeamTop(p map[string]interface{}) (res []StatItem) {
defer measure("StatTeamTop", time.Now())
mustSelectN(&res, fmt.Sprintf(teamTopQuery, p["item"], p["sort"]), p)
mustSelectN(&res, fmt.Sprintf(teamTopQuery, p["item"]), p)
return
}

View File

@ -19,12 +19,13 @@ type (
login string
}
statRequest struct {
Org string `structs:"org"`
Team string `structs:"team"`
User string `structs:"user"`
From int64 `structs:"from"`
To int64 `structs:"to"`
Item string `structs:"item"`
Org string `structs:"org"`
Team string `structs:"team"`
Author string `structs:"author"`
Repo string `structs:"repo"`
From int64 `structs:"from"`
To int64 `structs:"to"`
Item string `structs:"item"`
}
)
@ -84,12 +85,13 @@ func parseStatRequest(r *http.Request) *statRequest {
}
return &statRequest{
Org: r.FormValue("org"),
Team: r.FormValue("team"),
User: r.FormValue("user"),
From: from,
To: to,
Item: item,
Org: r.FormValue("org"),
Team: r.FormValue("team"),
Author: r.FormValue("author"),
Repo: r.FormValue("repo"),
From: from,
To: to,
Item: item,
}
}