Operational Integrations – EventConnect Synchronization
This section describes the EventConnect synchronization that keeps Prep Network events up-to-date with data from the external EventConnect API. It covers:
- The artisan command
app:event-connect-sync - The EventConnect integration client
- The per-event synchronization job
- Scheduling and operational workflow
Introduction
The EventConnect synchronization ensures upcoming events in Prep Network match the latest status and team data from the EventConnect platform. It:
- Fetches all pages of events via the EventConnect REST API
- Filters to only future events
- Dispatches background jobs to process each event’s updates
Components
1. Console Command
File: app/Console/Commands/EventConnectSync.php
protected $signature = 'app:event-connect-sync';
protected $description = 'Sync upcoming event teams and status with Event Connect';
-
handle():- Calls
retrieveEvents()to fetch all upcoming events. - If no events found, logs “No upcoming events found to sync.”
- Loops through
$eventsand dispatches\App\Jobs\EventConnectSyncfor each. - Logs the total dispatched count.
- Calls
-
retrieveEvents():- Initializes paging:
$currentPage = 1,$totalPages = 1. - Loops while
$currentPage <= $totalPages:- Calls
$eventConnect->get('events', ['page' => $currentPage]). - On successful response, merges
data['data']into$allEventsand readsmetadata.page.currentand.total. - Increments
$currentPage.
- Calls
- Filters to only events whose
startorenddate is after now viafilterUpcomingEvents(). - Logs “Retrieved X total events, filtering to Y upcoming events.”
- Returns the array of upcoming events.
- Initializes paging:
-
filterUpcomingEvents(array $events): array:
Usesarray_filterand Carbon to keep only events whose start or end date is in the future.
2. EventConnect Integration Client
File: app/Integrations/EventConnect.php
(Not shown in the snippet, but used by the command)
- Wraps API authentication and HTTP calls.
- Exposes methods like
get(string $path, array $query = []): Response. - Returns a Laravel HTTP client response for downstream parsing.
3. Synchronization Job
File: app/Jobs/EventConnectSync.php
(Assumed based on naming convention)
- Constructor accepts a single event payload (array).
handle():- Updates local event status, teams, or other related data based on the event payload.
- Handles errors and retries if necessary.
- Logs successes or failures.
Workflow
flowchart TD
A[Scheduler @ 3:00 AM] --> B[Artisan Command: app:event-connect-sync]
B --> C{retrieveEvents()}
C -->|pages 1…N| D[EventConnect Integration → API]
D --> E[Accumulate events]
E --> F[filterUpcomingEvents()]
F -->|upcoming events| G[Dispatch per-event Job]
G --> H[Job: EventConnectSync per event]
H --> I[Update local DB: status & teams]
I --> J[Log success or send failure alert]
Scheduling
The command is registered in the application scheduler:
| Schedule | Task | Method Chain |
|---|---|---|
| Daily at 3:00 AM 🕒 | app:event-connect-sync |
->dailyAt('3:00')->sentryMonitor()->onOneServer() |
This ensures synchronization runs once per day on a single server, monitored by Sentry.
Configuration & Dependencies
-
Environment
EnsureEVENTCONNECT_API_KEYor similar credentials are set in.env. -
HTTP Client
Utilizes Laravel’sHttpfaçade for API calls. -
Queue
Jobs dispatched rely on the configured queue driver. Ensure workers are running. -
Error Monitoring
sentryMonitor()wraps the scheduled command to capture exceptions.
Key Design Decisions
-
Pagination Handling
Uses metadata from the API to iterate through all pages. Prevents missing events when data grows. -
Event Filtering
Only processes events that haven’t started yet, reducing unnecessary loads on past events. -
Job Dispatching
Offloads per-event work to queued jobs for better scalability and fault isolation. -
Idempotency
Command and job implementations should handle re-runs safely (e.g., skip duplicates).
Note
For debugging, run:php artisan app:event-connect-syncand observe console output for retrieved counts and dispatch statuses.