Add more reports
This commit is contained in:
parent
9ed692aa10
commit
007e122a4a
@ -19,6 +19,9 @@ module.exports = React.createClass({
|
|||||||
if (reportId == "suggestion-veto-ratio") {
|
if (reportId == "suggestion-veto-ratio") {
|
||||||
this.props.fetchReport("suggestions");
|
this.props.fetchReport("suggestions");
|
||||||
this.props.fetchReport("vetoed-suggestions");
|
this.props.fetchReport("vetoed-suggestions");
|
||||||
|
} else if (reportId == "suggestor-veto-ratio") {
|
||||||
|
this.props.fetchReport("suggestors");
|
||||||
|
this.props.fetchReport("vetoed-suggestors");
|
||||||
} else {
|
} else {
|
||||||
this.props.fetchReport(reportId);
|
this.props.fetchReport(reportId);
|
||||||
}
|
}
|
||||||
@ -41,6 +44,13 @@ module.exports = React.createClass({
|
|||||||
title="Suggestion Veto Ratio"
|
title="Suggestion Veto Ratio"
|
||||||
numerator={this.props.reports['vetoed-suggestions'].Data}
|
numerator={this.props.reports['vetoed-suggestions'].Data}
|
||||||
denominator={this.props.reports['suggestions'].Data}/>);
|
denominator={this.props.reports['suggestions'].Data}/>);
|
||||||
|
} else if (this.state.selectedReportId == "suggestor-veto-ratio" &&
|
||||||
|
this.props.reports.hasOwnProperty("suggestors") &&
|
||||||
|
this.props.reports.hasOwnProperty("vetoed-suggestors")) {
|
||||||
|
chart=(<RatioBarChart
|
||||||
|
title="Suggestor Veto Ratio"
|
||||||
|
numerator={this.props.reports['vetoed-suggestors'].Data}
|
||||||
|
denominator={this.props.reports['suggestors'].Data}/>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -51,10 +61,14 @@ module.exports = React.createClass({
|
|||||||
id="lunch-report-selection-dropdown"
|
id="lunch-report-selection-dropdown"
|
||||||
onSelect={this.selectReport}>
|
onSelect={this.selectReport}>
|
||||||
<MenuItem eventKey="suggestions">Suggestion Frequency</MenuItem>
|
<MenuItem eventKey="suggestions">Suggestion Frequency</MenuItem>
|
||||||
<MenuItem eventKey="non-vetoed-suggestions">Non-Vetoed Suggestions</MenuItem>
|
<MenuItem eventKey="winning-suggestions">Winning Suggestions</MenuItem>
|
||||||
<MenuItem eventKey="vetoed-suggestions">Vetoed Suggestions</MenuItem>
|
<MenuItem eventKey="vetoed-suggestions">Vetoed Suggestions</MenuItem>
|
||||||
<MenuItem eventKey="suggestion-veto-ratio">Veto Ratio</MenuItem>
|
<MenuItem eventKey="suggestion-veto-ratio">Suggestion Veto Ratio</MenuItem>
|
||||||
<MenuItem eventKey="attendees">Attendee Frequency</MenuItem>
|
<MenuItem eventKey="attendees">Attendee Frequency</MenuItem>
|
||||||
|
<MenuItem eventKey="suggestors">Suggestor Frequency</MenuItem>
|
||||||
|
<MenuItem eventKey="winning-suggestors">Winning Suggestors</MenuItem>
|
||||||
|
<MenuItem eventKey="vetoed-suggestors">Vetoed Suggestors</MenuItem>
|
||||||
|
<MenuItem eventKey="suggestor-veto-ratio">Suggestor Veto Ratio</MenuItem>
|
||||||
</DropdownButton>
|
</DropdownButton>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
|
||||||
|
68
reports.go
68
reports.go
@ -80,7 +80,7 @@ func GetVetoedSuggestions(groupid int64) (*[]*Suggestion, error) {
|
|||||||
return &suggestions, nil
|
return &suggestions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetNonVetoedSuggestions(groupid int64) (*[]*Suggestion, error) {
|
func GetWinningSuggestions(groupid int64) (*[]*Suggestion, error) {
|
||||||
var suggestions []*Suggestion
|
var suggestions []*Suggestion
|
||||||
|
|
||||||
_, err := DB.Select(&suggestions, "SELECT suggestions.* FROM suggestions LEFT OUTER JOIN suggestions AS s2 ON suggestions.SuggestionId=s2.VetoingId WHERE s2.SuggestionId IS NULL AND suggestions.GroupId=?;", groupid)
|
_, err := DB.Select(&suggestions, "SELECT suggestions.* FROM suggestions LEFT OUTER JOIN suggestions AS s2 ON suggestions.SuggestionId=s2.VetoingId WHERE s2.SuggestionId IS NULL AND suggestions.GroupId=?;", groupid)
|
||||||
@ -102,6 +102,39 @@ func GetAllAttendees(groupid int64) (*[]*Attendee, error) {
|
|||||||
return &attendees, nil
|
return &attendees, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAllSuggestors(groupid int64) (*[]*Attendee, error) {
|
||||||
|
var suggestors []*Attendee
|
||||||
|
|
||||||
|
_, err := DB.Select(&suggestors, "SELECT attendees.* FROM attendees INNER JOIN suggestions ON suggestions.AttendeeId==attendees.AttendeeId WHERE suggestions.GroupId=?", groupid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &suggestors, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetVetoedSuggestors(groupid int64) (*[]*Attendee, error) {
|
||||||
|
var suggestors []*Attendee
|
||||||
|
|
||||||
|
_, err := DB.Select(&suggestors, "SELECT attendees.* FROM attendees INNER JOIN (SELECT suggestions.* FROM suggestions INNER JOIN suggestions AS s2 WHERE suggestions.GroupId=? AND s2.GroupId=? AND suggestions.Date=s2.Date AND s2.VetoingId=suggestions.SuggestionId) a ON a.AttendeeId==attendees.AttendeeId", groupid, groupid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &suggestors, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetWinningSuggestors(groupid int64) (*[]*Attendee, error) {
|
||||||
|
var suggestors []*Attendee
|
||||||
|
|
||||||
|
_, err := DB.Select(&suggestors, "SELECT attendees.* FROM attendees INNER JOIN (SELECT suggestions.* FROM suggestions LEFT OUTER JOIN suggestions AS s2 ON suggestions.SuggestionId=s2.VetoingId WHERE s2.SuggestionId IS NULL AND suggestions.GroupId=?) a ON a.AttendeeId==attendees.AttendeeId", groupid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &suggestors, nil
|
||||||
|
}
|
||||||
|
|
||||||
func ReportHandler(w http.ResponseWriter, r *http.Request) {
|
func ReportHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
user, err := GetUserFromSession(r)
|
user, err := GetUserFromSession(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -116,9 +149,9 @@ func ReportHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
reportid := query.Get("id")
|
reportid := query.Get("id")
|
||||||
report.ReportId = reportid
|
report.ReportId = reportid
|
||||||
|
|
||||||
if reportid == "non-vetoed-suggestions" {
|
if reportid == "winning-suggestions" {
|
||||||
report.Title = "Non-Vetoed Suggestions"
|
report.Title = "Winning Suggestions"
|
||||||
suggestions, err := GetNonVetoedSuggestions(user.GroupId)
|
suggestions, err := GetWinningSuggestions(user.GroupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
WriteError(w, 999 /*Internal Error*/)
|
WriteError(w, 999 /*Internal Error*/)
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
@ -152,6 +185,33 @@ func ReportHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
report.FromSummedAttendeeList(attendees)
|
report.FromSummedAttendeeList(attendees)
|
||||||
|
} else if reportid == "winning-suggestors" {
|
||||||
|
report.Title = "Winning Suggestors"
|
||||||
|
attendees, err := GetWinningSuggestors(user.GroupId)
|
||||||
|
if err != nil {
|
||||||
|
WriteError(w, 999 /*Internal Error*/)
|
||||||
|
log.Print(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
report.FromSummedAttendeeList(attendees)
|
||||||
|
} else if reportid == "vetoed-suggestors" {
|
||||||
|
report.Title = "Vetoed Suggestors"
|
||||||
|
attendees, err := GetVetoedSuggestors(user.GroupId)
|
||||||
|
if err != nil {
|
||||||
|
WriteError(w, 999 /*Internal Error*/)
|
||||||
|
log.Print(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
report.FromSummedAttendeeList(attendees)
|
||||||
|
} else if reportid == "suggestors" {
|
||||||
|
report.Title = "Suggestor Frequency"
|
||||||
|
attendees, err := GetAllSuggestors(user.GroupId)
|
||||||
|
if err != nil {
|
||||||
|
WriteError(w, 999 /*Internal Error*/)
|
||||||
|
log.Print(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
report.FromSummedAttendeeList(attendees)
|
||||||
} else {
|
} else {
|
||||||
WriteError(w, 3 /*Invalid Request*/)
|
WriteError(w, 3 /*Invalid Request*/)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user