Add Vetoing Suggestors report

This commit is contained in:
Aaron Lindsay 2017-01-11 09:52:05 -05:00
parent 2570a07d57
commit b578f3250d
2 changed files with 21 additions and 0 deletions

View File

@ -68,6 +68,7 @@ module.exports = React.createClass({
<MenuItem eventKey="suggestors">Suggestor Frequency</MenuItem>
<MenuItem eventKey="winning-suggestors">Winning Suggestors</MenuItem>
<MenuItem eventKey="vetoed-suggestors">Vetoed Suggestors</MenuItem>
<MenuItem eventKey="vetoing-suggestors">Vetoing Suggestors</MenuItem>
<MenuItem eventKey="suggestor-veto-ratio">Suggestor Veto Ratio</MenuItem>
</DropdownButton>
</ButtonGroup>

View File

@ -135,6 +135,17 @@ func GetWinningSuggestors(groupid int64) (*[]*Attendee, error) {
return &suggestors, nil
}
func GetVetoingSuggestors(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.VetoingId!=-1 AND suggestions.GroupId=?", groupid)
if err != nil {
return nil, err
}
return &suggestors, nil
}
func ReportHandler(w http.ResponseWriter, r *http.Request) {
user, err := GetUserFromSession(r)
if err != nil {
@ -203,6 +214,15 @@ func ReportHandler(w http.ResponseWriter, r *http.Request) {
return
}
report.FromSummedAttendeeList(attendees)
} else if reportid == "vetoing-suggestors" {
report.Title = "Vetoing Suggestors"
attendees, err := GetVetoingSuggestors(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)