Delete auto-RSVP on unclaim and count going from RSVPs only

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 23:15:48 -04:00
parent 6e3fc9721a
commit e7022124be
3 changed files with 36 additions and 9 deletions
+16 -9
View File
@@ -203,18 +203,10 @@ func (s *Server) loadEventPage(r *http.Request, slug string, isAdmin bool) (*Eve
totalGoing += 1 + r.PlusOne
}
// Build deduplicated GoingList: RSVPs first, then claim-only people
// Build GoingList from RSVPs only
var goingList []GoingPerson
seen := make(map[string]bool)
for _, r := range rsvps {
goingList = append(goingList, GoingPerson{Name: r.Name, Note: r.Note, RsvpID: r.ID, PlusOne: r.PlusOne})
seen[strings.ToLower(r.Name)] = true
}
for _, c := range claims {
if !seen[strings.ToLower(c.Name)] {
goingList = append(goingList, GoingPerson{Name: c.Name})
seen[strings.ToLower(c.Name)] = true
}
}
var descHTML template.HTML
@@ -271,6 +263,21 @@ func (s *Server) handleUnclaim(w http.ResponseWriter, r *http.Request) {
return
}
// Look up the claim to get the name, then delete the auto-created RSVP
claim, err := s.q.GetClaimByID(r.Context(), claimID)
if err == nil {
event, err := s.q.GetEventBySlug(r.Context(), slug)
if err == nil {
rsvp, err := s.q.GetRsvpByName(r.Context(), db.GetRsvpByNameParams{
EventID: event.ID,
Name: claim.Name,
})
if err == nil {
s.q.DeleteRsvp(r.Context(), rsvp.ID)
}
}
}
err = s.q.DeleteClaim(r.Context(), claimID)
if err != nil {
http.Error(w, "Failed to remove", http.StatusInternalServerError)