mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-17 16:40:31 +00:00
✨ Add attendee count helpers and enhance Meetup API responses
- ➕ Introduce `attendeesCount` and `mightAttendeesCount` methods in `MeetupEvent` model for cleaner attendee calculations. - 🛠️ Refactor API responses to use attendee count helpers in `Meetup` and `MeetupEventController`. - 🧪 Update tests to validate JSON structure with attendee-related fields (`id`, `attendees`, `might_attendees`).
This commit is contained in:
@@ -59,10 +59,13 @@ class MeetupEventController extends Controller
|
||||
->get();
|
||||
|
||||
return $events->map(fn ($event) => [
|
||||
'id' => $event->id,
|
||||
'start' => $event->start->format('Y-m-d H:i'),
|
||||
'location' => $event->location,
|
||||
'description' => $event->description,
|
||||
'link' => $event->link,
|
||||
'attendees' => $event->attendeesCount(),
|
||||
'might_attendees' => $event->mightAttendeesCount(),
|
||||
'meetup.name' => $event->meetup->name,
|
||||
'meetup.portalLink' => url()->route(
|
||||
'meetups.landingpage',
|
||||
@@ -202,8 +205,8 @@ class MeetupEventController extends Controller
|
||||
{
|
||||
return [
|
||||
'status' => $meetupEvent->rsvpStatusFor($user)->value,
|
||||
'attendees' => count($meetupEvent->attendees ?? []),
|
||||
'might_attendees' => count($meetupEvent->might_attendees ?? []),
|
||||
'attendees' => $meetupEvent->attendeesCount(),
|
||||
'might_attendees' => $meetupEvent->mightAttendeesCount(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,8 +272,8 @@ class Meetup extends Model implements HasMedia
|
||||
'location' => $nextEvent->location,
|
||||
'description' => $nextEvent->description,
|
||||
'link' => $nextEvent->link,
|
||||
'attendees' => count($nextEvent->attendees ?? []),
|
||||
'might_attendees' => count($nextEvent->might_attendees ?? []),
|
||||
'attendees' => $nextEvent->attendeesCount(),
|
||||
'might_attendees' => $nextEvent->mightAttendeesCount(),
|
||||
'nostr_note' => str($nextEvent->nostr_status)->after('Sent event ')->before(' to '),
|
||||
] : null,
|
||||
);
|
||||
|
||||
@@ -65,6 +65,19 @@ class MeetupEvent extends Model
|
||||
return $this->belongsTo(Meetup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzahl der Zusagen bzw. Vielleicht-Sagen (die Listen sind JSON-Arrays).
|
||||
*/
|
||||
public function attendeesCount(): int
|
||||
{
|
||||
return count($this->attendees ?? []);
|
||||
}
|
||||
|
||||
public function mightAttendeesCount(): int
|
||||
{
|
||||
return count($this->might_attendees ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eindeutige Kennung eines angemeldeten Nutzers in den Teilnehmer-Listen.
|
||||
* Einträge werden als `id_<userId>|<name>` abgelegt; der angehängte Pipe
|
||||
|
||||
Reference in New Issue
Block a user