diff --git a/app/index.html b/app/index.html index e9226fa..251c717 100644 --- a/app/index.html +++ b/app/index.html @@ -29,6 +29,7 @@ + @@ -39,6 +40,5 @@ - diff --git a/app/jsx/charts/bc/bar_chart.jsx b/app/jsx/charts/bc/bar_chart.jsx index c0938e1..c2981dd 100644 --- a/app/jsx/charts/bc/bar_chart.jsx +++ b/app/jsx/charts/bc/bar_chart.jsx @@ -143,7 +143,7 @@ var BarChart = React.createClass({ return (
- This bar chart shows {words.values[this.state.sort]} {words.actions[this.state.item +'-'+ this.state.sort]} {words.items[this.state.item]} {words.whatHappened[this.state.item +'-'+ target]} {subject} {words.targetSuffix[target]}
+ This bar chart shows {words.values[this.state.sort]} {words.actions[this.state.item +'-'+ this.state.sort]} {words.items[this.state.item]} {words.whatHappened[this.state.item +'-'+ target]} {subject} {words.targetSuffix[target]}
- This stacked area chart shows the number of commits {words.actions[this.state.item]} {words.items[this.state.item]} {words.whatHappened[this.state.item +'-'+ target]} {subject} {words.targetSuffix[target]}
+ This stacked area chart shows the number of commits {words.actions[this.state.item]} {words.items[this.state.item]} {words.whatHappened[this.state.item +'-'+ target]} {subject} {words.targetSuffix[target]}
= firstWeek; i -= weekSeconds) { - weeks.push(i); - }; - return { - weeks: weeks.sort() + weeks: [] }; }, + componentDidMount: function() { + this.loadWeekRange(this.props.org); + }, + + componentWillReceiveProps: function(newProps) { + this.loadWeekRange(newProps.org); + }, + handleChange: function(thing, e) { var params = this.getQuery(); params[thing.slice(0, 1)] = e.target.value/100; this.transitionTo(document.location.pathname, null, params); }, + loadWeekRange: function(org) { + getURL("/api/weeks", {org: org}, function(res){ + var weeks = [], + min = res[0], + max = res[1]; + for (var i = min; i <= max; i += 86400*7) { + weeks.push(i); + }; + this.setState({ + weeks: weeks + }); + }.bind(this)); + }, + render: function() { var daySeconds = 86400, weekSeconds = daySeconds*7, diff --git a/db/org.go b/db/org.go index d69efff..b755098 100644 --- a/db/org.go +++ b/db/org.go @@ -36,3 +36,18 @@ func UserOrgs(login string) (orgs []*Org) { `, login) return } + +func OrgWeekRange(login string) (min int, max int) { + row := db.QueryRow(` + select + min(c.week) as min, + max(c.week) as max + from contribs c + join orgs o on o.id = c.org_id + where o.login = ? + `, login) + if err := row.Scan(&min, &max); err != nil { + panic(err) + } + return +} diff --git a/server/api.go b/server/api.go index 64b021b..01e4c1d 100644 --- a/server/api.go +++ b/server/api.go @@ -29,3 +29,9 @@ func apiReposHandler(w http.ResponseWriter, r *http.Request) { repos := db.OrgRepos(stat.Org) req.respondWith(repos) } + +func apiOrgWeekRangeHandler(w http.ResponseWriter, r *http.Request) { + req, stat := parseRequest(w, r) + min, max := db.OrgWeekRange(stat.Org) + req.respondWith([]int{min, max}) +} diff --git a/server/server.go b/server/server.go index 311edeb..da1e142 100644 --- a/server/server.go +++ b/server/server.go @@ -26,6 +26,7 @@ func init() { http.HandleFunc("/api/teams", apiTeamsHandler) http.HandleFunc("/api/users", apiUsersHandler) http.HandleFunc("/api/repos", apiReposHandler) + http.HandleFunc("/api/weeks", apiOrgWeekRangeHandler) http.HandleFunc("/api/stat/orgs/top", statOrgTopHandler) http.HandleFunc("/api/stat/orgs/activity", statOrgActivityHandler)