Fix null volunteers array in shift instance JSON responses
Initialize slice helpers with make() instead of var declaration so empty results serialize as [] instead of null in JSON, fixing the frontend TypeError on the schedules page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -590,7 +590,7 @@ func (s *Store) templateRoles(ctx context.Context, templateID int64) ([]Template
|
||||
return nil, fmt.Errorf("get template roles: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
var roles []TemplateRole
|
||||
roles := make([]TemplateRole, 0)
|
||||
for rows.Next() {
|
||||
var r TemplateRole
|
||||
if err := rows.Scan(&r.ID, &r.TemplateID, &r.RoleName, &r.Count); err != nil {
|
||||
@@ -608,7 +608,7 @@ func (s *Store) templateVolunteerIDs(ctx context.Context, templateID int64) ([]i
|
||||
return nil, fmt.Errorf("get template volunteers: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
var ids []int64
|
||||
ids := make([]int64, 0)
|
||||
for rows.Next() {
|
||||
var id int64
|
||||
if err := rows.Scan(&id); err != nil {
|
||||
@@ -631,7 +631,7 @@ func (s *Store) instanceVolunteers(ctx context.Context, instanceID int64) ([]Ins
|
||||
return nil, fmt.Errorf("get instance volunteers: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
var vols []InstanceVolunteer
|
||||
vols := make([]InstanceVolunteer, 0)
|
||||
for rows.Next() {
|
||||
var iv InstanceVolunteer
|
||||
var confirmedAt sql.NullString
|
||||
|
||||
Reference in New Issue
Block a user