Show RSVP and non-RSVP donation totals on report page
This commit is contained in:
12
main.go
12
main.go
@@ -565,11 +565,13 @@ func handleReport(w http.ResponseWriter, r *http.Request) {
|
|||||||
EventID string `json:"eventId"`
|
EventID string `json:"eventId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
TotalPeople int `json:"totalPeople"`
|
TotalPeople int `json:"totalPeople"`
|
||||||
|
TotalRsvpDonated float64 `json:"totalRsvpDonated"`
|
||||||
|
TotalOtherDonated float64 `json:"totalOtherDonated"`
|
||||||
TotalDonated float64 `json:"totalDonated"`
|
TotalDonated float64 `json:"totalDonated"`
|
||||||
RSVPs []rsvpRow `json:"rsvps"`
|
RSVPs []rsvpRow `json:"rsvps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := db.Query("SELECT event_id, google_username, num_people, donation FROM rsvps WHERE num_people > 0 ORDER BY event_id, google_username")
|
rows, err := db.Query("SELECT event_id, google_username, num_people, donation FROM rsvps ORDER BY event_id, google_username")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("[ERROR] failed to query rsvps for report:", err)
|
log.Println("[ERROR] failed to query rsvps for report:", err)
|
||||||
http.Error(w, "database error", http.StatusInternalServerError)
|
http.Error(w, "database error", http.StatusInternalServerError)
|
||||||
@@ -595,9 +597,15 @@ func handleReport(w http.ResponseWriter, r *http.Request) {
|
|||||||
summary = &eventSummary{EventID: r.EventID, Name: name, RSVPs: []rsvpRow{}}
|
summary = &eventSummary{EventID: r.EventID, Name: name, RSVPs: []rsvpRow{}}
|
||||||
eventMap[r.EventID] = summary
|
eventMap[r.EventID] = summary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.NumPeople > 0 {
|
||||||
summary.TotalPeople += r.NumPeople
|
summary.TotalPeople += r.NumPeople
|
||||||
summary.TotalDonated += r.Donation
|
summary.TotalRsvpDonated += r.Donation
|
||||||
summary.RSVPs = append(summary.RSVPs, r)
|
summary.RSVPs = append(summary.RSVPs, r)
|
||||||
|
} else if r.Donation > 0 {
|
||||||
|
summary.TotalOtherDonated += r.Donation
|
||||||
|
}
|
||||||
|
summary.TotalDonated += r.Donation
|
||||||
}
|
}
|
||||||
|
|
||||||
result := []eventSummary{}
|
result := []eventSummary{}
|
||||||
|
|||||||
@@ -60,6 +60,8 @@
|
|||||||
summary.className = 'summary';
|
summary.className = 'summary';
|
||||||
summary.innerHTML = `
|
summary.innerHTML = `
|
||||||
<div>Total RSVPs: <strong>${event.totalPeople}</strong></div>
|
<div>Total RSVPs: <strong>${event.totalPeople}</strong></div>
|
||||||
|
<div>RSVP Donations: <strong>$${event.totalRsvpDonated.toFixed(2)}</strong></div>
|
||||||
|
<div>Other Donations: <strong>$${event.totalOtherDonated.toFixed(2)}</strong></div>
|
||||||
<div>Total Donated: <strong>$${event.totalDonated.toFixed(2)}</strong></div>
|
<div>Total Donated: <strong>$${event.totalDonated.toFixed(2)}</strong></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user