From a226af424fda4e92d90f307bf7add20e92a7cfbd Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Fri, 31 Jan 2025 17:28:44 -0500 Subject: [PATCH 1/7] ll --- .../Controllers/CalendarFeedController.php | 82 ++++++ composer.json | 1 + composer.lock | 139 +++++++++- resources/views/calendar-feed/index.blade.php | 259 ++++++++++++++++++ resources/views/calendar/index.blade.php | 2 + .../components/calendar-feed-promo.blade.php | 63 +++++ resources/views/events/index.blade.php | 100 +++---- resources/views/orgs/show.blade.php | 213 +++++++------- routes/web.php | 5 + 9 files changed, 713 insertions(+), 151 deletions(-) create mode 100644 app/Http/Controllers/CalendarFeedController.php create mode 100644 resources/views/calendar-feed/index.blade.php create mode 100644 resources/views/components/calendar-feed-promo.blade.php diff --git a/app/Http/Controllers/CalendarFeedController.php b/app/Http/Controllers/CalendarFeedController.php new file mode 100644 index 00000000..633d98c3 --- /dev/null +++ b/app/Http/Controllers/CalendarFeedController.php @@ -0,0 +1,82 @@ + Org::query() + ->with('category') + ->where('status', OrganizationStatus::Active) + ->orderBy('title') + ->get() + ->map(fn(Org $org) => [ + 'id' => $org->id, + 'title' => $org->title, + 'checked' => true, + ]), + ]); + } + + public function show(Request $request) + { + $organization_ids = collect(explode('-', $request->input('orgs'))); + + $organizations = Org::query() + ->where('status', OrganizationStatus::Active) + ->when($organization_ids->isNotEmpty(), fn($query) => $query->whereIn('id', $organization_ids)) + ->get(); + + $events = Event::query() + ->with('organization', 'venue.state') + ->future() + ->when($organization_ids->isNotEmpty(), fn($query) => $query->whereIn('organization_id', $organization_ids)) + ->get() + ->mapWithKeys(function(Event $event, $i) { + return [ + $i => CalendarEvent::create($event->event_name) + ->uniqueIdentifier($event->uniqueIdentifierHash()) + ->startsAt($event->active_at) + ->endsAt($event->expire_at) + ->address($event->venue?->fullAddress() ?? 'Virtual Event') + ->description($event->description) + ->url($event->url), + ]; + }) + ->toArray(); + + // Calendar + $calendar = Calendar::create() + ->timezone(['America/New_York']); + + if ($organizations->count() === 1) { + $organization = $organizations->first(); + + $calendar + ->productIdentifier($organization->title.' Event Calendar') + ->name($organization->title.' Event Calendar') + ->description($organization->description ?? '') + ->source(route('orgs.show', $organization)); + } else { + $calendar + ->productIdentifier('HackGreenville.com Event Calendar') + ->name('HackGreenville Event Calendar') + ->description('Tech Events in Greenville SC!') + ->source(route('calendar.index')); + } + + $data = $calendar->event($events)->get(); + + return response($data) + ->header('Content-Type', 'text/calendar; charset=utf-8'); + } +} diff --git a/composer.json b/composer.json index 790ad47e..6c56a78a 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "laravel/tinker": "^2.0", "malzariey/filament-daterangepicker-filter": "^2.7", "scyllaly/hcaptcha": "^4.4", + "spatie/icalendar-generator": "^2.9", "spatie/laravel-data": "*" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 31064666..255585e2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bce519f240533e305ebf2b2f604f0bbe", + "content-hash": "227e8fe549cc13ceb553d8eaadf19e82", "packages": [ { "name": "amphp/amp", @@ -7987,6 +7987,141 @@ ], "time": "2024-09-20T14:00:15+00:00" }, + { + "name": "spatie/enum", + "version": "3.13.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/enum.git", + "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/enum/zipball/f1a0f464ba909491a53e60a955ce84ad7cd93a2c", + "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^8.0" + }, + "require-dev": { + "fakerphp/faker": "^1.9.1", + "larapack/dd": "^1.1", + "phpunit/phpunit": "^9.0", + "vimeo/psalm": "^4.3" + }, + "suggest": { + "fakerphp/faker": "To use the enum faker provider", + "phpunit/phpunit": "To use the enum assertions" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Enum\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brent Roose", + "email": "brent@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + }, + { + "name": "Tom Witkowski", + "email": "dev@gummibeer.de", + "homepage": "https://gummibeer.de", + "role": "Developer" + } + ], + "description": "PHP Enums", + "homepage": "https://github.com/spatie/enum", + "keywords": [ + "enum", + "enumerable", + "spatie" + ], + "support": { + "docs": "https://docs.spatie.be/enum", + "issues": "https://github.com/spatie/enum/issues", + "source": "https://github.com/spatie/enum" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-04-22T08:51:55+00:00" + }, + { + "name": "spatie/icalendar-generator", + "version": "2.9.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/icalendar-generator.git", + "reference": "21b8d259156368812a6d55096499f289b265be4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/icalendar-generator/zipball/21b8d259156368812a6d55096499f289b265be4e", + "reference": "21b8d259156368812a6d55096499f289b265be4e", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^8.1", + "spatie/enum": "^3.11" + }, + "require-dev": { + "ext-json": "*", + "larapack/dd": "^1.1", + "nesbot/carbon": "^3.5", + "pestphp/pest": "^2.34", + "spatie/pest-plugin-snapshots": "^2.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\IcalendarGenerator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ruben Van Assche", + "email": "ruben@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Build calendars in the iCalendar format", + "homepage": "https://github.com/spatie/icalendar-generator", + "keywords": [ + "calendar", + "iCalendar", + "ical", + "ics", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/icalendar-generator/issues", + "source": "https://github.com/spatie/icalendar-generator/tree/2.9.1" + }, + "time": "2025-01-31T13:50:13+00:00" + }, { "name": "spatie/invade", "version": "2.1.0", @@ -13878,5 +14013,5 @@ "ext-pdo_sqlite": "*", "ext-sqlite3": "*" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } diff --git a/resources/views/calendar-feed/index.blade.php b/resources/views/calendar-feed/index.blade.php new file mode 100644 index 00000000..538b10f6 --- /dev/null +++ b/resources/views/calendar-feed/index.blade.php @@ -0,0 +1,259 @@ +@extends('layouts.app', ['show_loading' => true]) + +@section('title', "Build a Calendar Feed of the events you're interested in") +@section('description', 'A monthly calendar view of upcoming tech events in the Greenville, SC area.') + +@section('content') +
+
+
+
+

+ Curated Event Feed +

+
+
+ +
+
+ + +
+ Select All / None +
+ +
+ + + + +
+
+
+ + + +@endsection diff --git a/resources/views/calendar/index.blade.php b/resources/views/calendar/index.blade.php index 75bba8d8..579b8de3 100644 --- a/resources/views/calendar/index.blade.php +++ b/resources/views/calendar/index.blade.php @@ -5,6 +5,8 @@ @section('content')
+ +
@endsection diff --git a/resources/views/components/calendar-feed-promo.blade.php b/resources/views/components/calendar-feed-promo.blade.php new file mode 100644 index 00000000..b7aa89df --- /dev/null +++ b/resources/views/components/calendar-feed-promo.blade.php @@ -0,0 +1,63 @@ + +
+
+
+
+ + +
+ +
+
+
diff --git a/resources/views/events/index.blade.php b/resources/views/events/index.blade.php index 5d32983f..bfad569b 100644 --- a/resources/views/events/index.blade.php +++ b/resources/views/events/index.blade.php @@ -2,65 +2,69 @@ @section('title', 'List of Greenville, SC Area Tech Events') @section('description', 'A list view of upcoming tech events happening in the Greenville, SC area.') -@section('canonical')@endsection +@section('canonical') + +@endsection @section('content') -
-

Upcoming Events

+
+

Upcoming Events

+ + -
-
+
+ - - -
+ + +
- @foreach($months as $month => $events) -
-

- {{ $month }} -

- @foreach($events as $event) - @include('events._item', ['event' => $event]) - @endforeach -
+ @foreach($months as $month => $events) +
+

+ {{ $month }} +

+ @foreach($events as $event) + @include('events._item', ['event' => $event]) + @endforeach +
- @endforeach + @endforeach - + -
+
@endsection @section('js') - + events.show(); + }); + }); + @endsection diff --git a/resources/views/orgs/show.blade.php b/resources/views/orgs/show.blade.php index 1a092617..03d4cbc9 100644 --- a/resources/views/orgs/show.blade.php +++ b/resources/views/orgs/show.blade.php @@ -4,109 +4,120 @@ @section('description', 'Highlights of the '. $org->title . ' organization of '. $org->city . ', SC, including upcoming events, organizer, and history.') @section('content') -
-

- {{ $org->title }} -

+
+
+
+

+ {{ $org->title }} +

+
-
- {!! $org->description !!} -
+ +
- - - @if($org->event_calendar_uri) - - - - - @endif - @if($org->uri) - - - - - @endif - - - - - - - - - - - - - - - - - - - - - @if($org->inactive_at) - - - - - @endif - - - - - -
- Event Homepage - - {{ $org->event_calendar_uri }} -
- Organization Homepage - - {{ $org->uri }} -
- City - - {{ $org->city }} -
- Focus Area - - {{ $org->focus_area }} -
- Contact Person - - {{ $org->primary_contact_person }} -
- Organization Type - - {{ $org->organization_type }} -
- Year Established - - {{ $org->established_at->year }} -
- Year Inactive - - {{ $org->inactive_at->year }} -
- Organization Status - -
- @if($org->isActive()) - Active - @else - Inactive - @endif -
-
+
+ {!! $org->description !!} +
- @if($org->events->isNotEmpty()) -

Upcoming Events

- @foreach($org->events as $event) - @include('events._item', ['event' => $event]) - @endforeach - @endif + + + @if($org->event_calendar_uri) + + + + + @endif + @if($org->uri) + + + + + @endif + + + + + + + + + + + + + + + + + + + + + @if($org->inactive_at) + + + + + @endif + + + + + +
+ Event Homepage + + {{ $org->event_calendar_uri }} +
+ Organization Homepage + + {{ $org->uri }} +
+ City + + {{ $org->city }} +
+ Focus Area + + {{ $org->focus_area }} +
+ Contact Person + + {{ $org->primary_contact_person }} +
+ Organization Type + + {{ $org->organization_type }} +
+ Year Established + + {{ $org->established_at->year }} +
+ Year Inactive + + {{ $org->inactive_at->year }} +
+ Organization Status + +
+ @if($org->isActive()) + Active + @else + Inactive + @endif +
+
+ + @if($org->events->isNotEmpty()) +

Upcoming Events

+ @foreach($org->events as $event) + @include('events._item', ['event' => $event]) + @endforeach + @endif
@endsection diff --git a/routes/web.php b/routes/web.php index 7010545e..90d19c90 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ name('home'); Route::get('/calendar', [CalendarController::class, 'index'])->name('calendar.index'); Route::get('/calendar/data', [CalendarController::class, 'data'])->name('calendar.data'); + +Route::get('/calendar-feed', [CalendarFeedController::class, 'index'])->name('calendar-feed.index'); +Route::get('/calendar-feed.ics', [CalendarFeedController::class, 'show'])->name('calendar-feed.show'); + Route::get('/events', [EventsController::class, 'index'])->name('events.index'); Route::get('/labs', [LabsController::class, 'index'])->name('labs.index'); Route::get('/hg-nights', [HGNightsController::class, 'index'])->name('hg-nights.index'); From b673e841d1f8df0b1b4252cf9dfc60acd6c7de19 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Fri, 31 Jan 2025 17:29:59 -0500 Subject: [PATCH 2/7] ll --- resources/views/orgs/show.blade.php | 222 ++++++++++++++-------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/resources/views/orgs/show.blade.php b/resources/views/orgs/show.blade.php index 03d4cbc9..e5011ff4 100644 --- a/resources/views/orgs/show.blade.php +++ b/resources/views/orgs/show.blade.php @@ -4,120 +4,120 @@ @section('description', 'Highlights of the '. $org->title . ' organization of '. $org->city . ', SC, including upcoming events, organizer, and history.') @section('content') -
-
-
-

- {{ $org->title }} -

-
+
+
+
+

+ {{ $org->title }} +

+
- -
+ +
-
- {!! $org->description !!} -
+
+ {!! $org->description !!} +
- - - @if($org->event_calendar_uri) - - - - - @endif - @if($org->uri) - - - - - @endif - - - - - - - - - - - - - - - - - - - - - @if($org->inactive_at) - - - - - @endif - - - - - -
- Event Homepage - - {{ $org->event_calendar_uri }} -
- Organization Homepage - - {{ $org->uri }} -
- City - - {{ $org->city }} -
- Focus Area - - {{ $org->focus_area }} -
- Contact Person - - {{ $org->primary_contact_person }} -
- Organization Type - - {{ $org->organization_type }} -
- Year Established - - {{ $org->established_at->year }} -
- Year Inactive - - {{ $org->inactive_at->year }} -
- Organization Status - -
- @if($org->isActive()) - Active - @else - Inactive - @endif -
-
+ + + @if($org->event_calendar_uri) + + + + + @endif + @if($org->uri) + + + + + @endif + + + + + + + + + + + + + + + + + + + + + @if($org->inactive_at) + + + + + @endif + + + + + +
+ Event Homepage + + {{ $org->event_calendar_uri }} +
+ Organization Homepage + + {{ $org->uri }} +
+ City + + {{ $org->city }} +
+ Focus Area + + {{ $org->focus_area }} +
+ Contact Person + + {{ $org->primary_contact_person }} +
+ Organization Type + + {{ $org->organization_type }} +
+ Year Established + + {{ $org->established_at->year }} +
+ Year Inactive + + {{ $org->inactive_at->year }} +
+ Organization Status + +
+ @if($org->isActive()) + Active + @else + Inactive + @endif +
+
- @if($org->events->isNotEmpty()) -

Upcoming Events

- @foreach($org->events as $event) - @include('events._item', ['event' => $event]) - @endforeach - @endif + @if($org->events->isNotEmpty()) +

Upcoming Events

+ @foreach($org->events as $event) + @include('events._item', ['event' => $event]) + @endforeach + @endif
@endsection From 4b2e275322cacf42a45d95667e6de858f882afc6 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Fri, 31 Jan 2025 17:38:38 -0500 Subject: [PATCH 3/7] pint --- .../Controllers/CalendarFeedController.php | 30 +++++++++---------- resources/views/orgs/show.blade.php | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/CalendarFeedController.php b/app/Http/Controllers/CalendarFeedController.php index 633d98c3..8bbb9958 100644 --- a/app/Http/Controllers/CalendarFeedController.php +++ b/app/Http/Controllers/CalendarFeedController.php @@ -19,7 +19,7 @@ public function index() ->where('status', OrganizationStatus::Active) ->orderBy('title') ->get() - ->map(fn(Org $org) => [ + ->map(fn (Org $org) => [ 'id' => $org->id, 'title' => $org->title, 'checked' => true, @@ -33,25 +33,23 @@ public function show(Request $request) $organizations = Org::query() ->where('status', OrganizationStatus::Active) - ->when($organization_ids->isNotEmpty(), fn($query) => $query->whereIn('id', $organization_ids)) + ->when($organization_ids->isNotEmpty(), fn ($query) => $query->whereIn('id', $organization_ids)) ->get(); $events = Event::query() ->with('organization', 'venue.state') ->future() - ->when($organization_ids->isNotEmpty(), fn($query) => $query->whereIn('organization_id', $organization_ids)) + ->when($organization_ids->isNotEmpty(), fn ($query) => $query->whereIn('organization_id', $organization_ids)) ->get() - ->mapWithKeys(function(Event $event, $i) { - return [ - $i => CalendarEvent::create($event->event_name) - ->uniqueIdentifier($event->uniqueIdentifierHash()) - ->startsAt($event->active_at) - ->endsAt($event->expire_at) - ->address($event->venue?->fullAddress() ?? 'Virtual Event') - ->description($event->description) - ->url($event->url), - ]; - }) + ->mapWithKeys(fn (Event $event, $i) => [ + $i => CalendarEvent::create($event->event_name) + ->uniqueIdentifier($event->uniqueIdentifierHash()) + ->startsAt($event->active_at) + ->endsAt($event->expire_at) + ->address($event->venue?->fullAddress() ?? 'Virtual Event') + ->description($event->description) + ->url($event->url), + ]) ->toArray(); // Calendar @@ -62,8 +60,8 @@ public function show(Request $request) $organization = $organizations->first(); $calendar - ->productIdentifier($organization->title.' Event Calendar') - ->name($organization->title.' Event Calendar') + ->productIdentifier($organization->title . ' Event Calendar') + ->name($organization->title . ' Event Calendar') ->description($organization->description ?? '') ->source(route('orgs.show', $organization)); } else { diff --git a/resources/views/orgs/show.blade.php b/resources/views/orgs/show.blade.php index e5011ff4..995f8ad9 100644 --- a/resources/views/orgs/show.blade.php +++ b/resources/views/orgs/show.blade.php @@ -13,7 +13,7 @@
- +
Subscribe to Calendar
From 2f2d9a2fe3dc43cc066227ec3c2b261bbd32d527 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Fri, 31 Jan 2025 17:41:12 -0500 Subject: [PATCH 4/7] pint --- resources/views/calendar-feed/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/calendar-feed/index.blade.php b/resources/views/calendar-feed/index.blade.php index 538b10f6..077914a4 100644 --- a/resources/views/calendar-feed/index.blade.php +++ b/resources/views/calendar-feed/index.blade.php @@ -1,4 +1,4 @@ -@extends('layouts.app', ['show_loading' => true]) +@extends('layouts.app') @section('title', "Build a Calendar Feed of the events you're interested in") @section('description', 'A monthly calendar view of upcoming tech events in the Greenville, SC area.') From 0b193c5b420bdefec3dd713c09728df53a850059 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Fri, 31 Jan 2025 22:39:50 -0500 Subject: [PATCH 5/7] Handle event status --- app/Http/Controllers/CalendarFeedController.php | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/CalendarFeedController.php b/app/Http/Controllers/CalendarFeedController.php index 8bbb9958..e548e7f1 100644 --- a/app/Http/Controllers/CalendarFeedController.php +++ b/app/Http/Controllers/CalendarFeedController.php @@ -8,6 +8,7 @@ use Illuminate\Http\Request; use Spatie\IcalendarGenerator\Components\Calendar; use Spatie\IcalendarGenerator\Components\Event as CalendarEvent; +use Spatie\IcalendarGenerator\Enums\EventStatus; class CalendarFeedController extends Controller { @@ -46,6 +47,10 @@ public function show(Request $request) ->uniqueIdentifier($event->uniqueIdentifierHash()) ->startsAt($event->active_at) ->endsAt($event->expire_at) + ->status(match ($event->isCancelled()) { + true => EventStatus::cancelled(), + default => EventStatus::confirmed(), + }) ->address($event->venue?->fullAddress() ?? 'Virtual Event') ->description($event->description) ->url($event->url), diff --git a/package.json b/package.json index 7aec6f11..7a4e0ef9 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test": "echo 'Running art test'", "posttest": "php artisan test --parallel", "lint": "prettier --write \"resources/{js,scss}/**/*.{ts,tsx,md,json,js,scss}\" --loglevel=error", - "lint:php": "composer lint --silent" + "lint:php": "composer lint --dev" }, "pre-commit": [ "lint", From fe03bd9c494b31be8366e7679a93ebde10de2473 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Fri, 31 Jan 2025 22:40:04 -0500 Subject: [PATCH 6/7] Lint --- .../src/Services/EventBriteHandler.php | 8 +++----- .../src/Services/MeetupGraphqlHandler.php | 2 +- app/Console/Kernel.php | 2 +- app/Http/Controllers/OrgsController.php | 6 ++---- app/Models/Org.php | 2 +- app/Models/State.php | 2 +- app/Models/Tag.php | 2 +- app/Models/Venue.php | 2 +- app/Providers/RouteServiceProvider.php | 2 +- app/Providers/TelescopeServiceProvider.php | 14 +++++--------- tests/Feature/JoinSlackTest.php | 6 ++---- 11 files changed, 19 insertions(+), 29 deletions(-) diff --git a/app-modules/event-importer/src/Services/EventBriteHandler.php b/app-modules/event-importer/src/Services/EventBriteHandler.php index d3e4744c..af607256 100644 --- a/app-modules/event-importer/src/Services/EventBriteHandler.php +++ b/app-modules/event-importer/src/Services/EventBriteHandler.php @@ -44,11 +44,9 @@ protected function mapIntoVenueData(array $data): ?VenueData $venue_id = $data['venue_id']; // Cache to prevent unnecessary api calls for same venue id - $venue = Cache::remember(__CLASS__ . __FUNCTION__ . $venue_id, now()->addHour(), function () use ($venue_id) { - return $this->client() - ->get("v3/venues/{$venue_id}") - ->object(); - }); + $venue = Cache::remember(__CLASS__ . __FUNCTION__ . $venue_id, now()->addHour(), fn () => $this->client() + ->get("v3/venues/{$venue_id}") + ->object()); return VenueData::from([ 'id' => $venue->id, diff --git a/app-modules/event-importer/src/Services/MeetupGraphqlHandler.php b/app-modules/event-importer/src/Services/MeetupGraphqlHandler.php index 053f7f06..e6706504 100644 --- a/app-modules/event-importer/src/Services/MeetupGraphqlHandler.php +++ b/app-modules/event-importer/src/Services/MeetupGraphqlHandler.php @@ -217,7 +217,7 @@ private function filterEvents(array $events): array $filtered_events = []; - foreach($events as $event) { + foreach ($events as $event) { $eventDate = Carbon::parse($event['node']['dateTime']); if ($eventDate < $start_date || $eventDate > $end_date) { continue; diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c8e724bd..3b602cc3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -21,7 +21,7 @@ protected function schedule(Schedule $schedule) $schedule->command(PruneMissingEventsCommand::class)->dailyAt('02:00'); - if(config('telescope.enabled')) { + if (config('telescope.enabled')) { $schedule->command('telescope:prune')->daily(); } } diff --git a/app/Http/Controllers/OrgsController.php b/app/Http/Controllers/OrgsController.php index 09f42c0a..16e7938a 100644 --- a/app/Http/Controllers/OrgsController.php +++ b/app/Http/Controllers/OrgsController.php @@ -12,11 +12,9 @@ public function index() $activeOrgs = Org::with('category') ->orderBy('title') ->get() - ->sortBy(function (Org $org) { - return $org->category->isInactive() + ->sortBy(fn (Org $org) => $org->category->isInactive() ? PHP_INT_MAX - : $org->category->count(); - }, SORT_NUMERIC) + : $org->category->count(), SORT_NUMERIC) ->groupBy('category_id'); return view('orgs.index', compact('activeOrgs')); diff --git a/app/Models/Org.php b/app/Models/Org.php index dd55220d..bef62895 100644 --- a/app/Models/Org.php +++ b/app/Models/Org.php @@ -31,7 +31,7 @@ * @property \Illuminate\Support\Carbon|null $deleted_at * @property-read Category|null $category * @property-read mixed $url - * @property-read \Illuminate\Database\Eloquent\Collection $tags + * @property-read \Illuminate\Database\Eloquent\Collection $tags * @property-read int|null $tags_count * @method static \Database\Factories\OrgFactory factory($count = null, $state = []) * @method static \Illuminate\Database\Eloquent\Builder|Org newModelQuery() diff --git a/app/Models/State.php b/app/Models/State.php index 2ab9291d..888c06cf 100644 --- a/app/Models/State.php +++ b/app/Models/State.php @@ -15,7 +15,7 @@ * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $deleted_at - * @property-read \Illuminate\Database\Eloquent\Collection $venues + * @property-read \Illuminate\Database\Eloquent\Collection $venues * @property-read int|null $venues_count * @method static \Illuminate\Database\Eloquent\Builder|State abbr($abbr) * @method static \Database\Factories\StateFactory factory($count = null, $state = []) diff --git a/app/Models/Tag.php b/app/Models/Tag.php index d3f5c591..34142db6 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -10,7 +10,7 @@ * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @property string|null $deleted_at - * @property-read \Illuminate\Database\Eloquent\Collection $orgs + * @property-read \Illuminate\Database\Eloquent\Collection $orgs * @property-read int|null $orgs_count * @method static \Database\Factories\TagFactory factory($count = null, $state = []) * @method static \Illuminate\Database\Eloquent\Builder|Tag newModelQuery() diff --git a/app/Models/Venue.php b/app/Models/Venue.php index 63a139f1..2d7e655d 100644 --- a/app/Models/Venue.php +++ b/app/Models/Venue.php @@ -23,7 +23,7 @@ * @property string|null $lat * @property string|null $lng * @property string|null $country - * @property-read \Illuminate\Database\Eloquent\Collection $events + * @property-read \Illuminate\Database\Eloquent\Collection $events * @property-read int|null $events_count * @property-read State|null $state * @method static \Database\Factories\VenueFactory factory($count = null, $state = []) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 58b6d030..af05e845 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -24,7 +24,7 @@ class RouteServiceProvider extends ServiceProvider */ public function boot() { - if(config('app.force_ssl')) { + if (config('app.force_ssl')) { URL::forceScheme('https'); } parent::boot(); diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php index 56077f90..967d1018 100644 --- a/app/Providers/TelescopeServiceProvider.php +++ b/app/Providers/TelescopeServiceProvider.php @@ -14,7 +14,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider */ public function register(): void { - if( ! config('telescope.enabled')) { + if ( ! config('telescope.enabled')) { return; } @@ -22,13 +22,11 @@ public function register(): void $this->hideSensitiveRequestDetails(); - Telescope::filter(function (IncomingEntry $entry) { - return $entry->isReportableException() || + Telescope::filter(fn (IncomingEntry $entry) => $entry->isReportableException() || $entry->isFailedRequest() || $entry->isFailedJob() || $entry->isScheduledTask() || - $entry->hasMonitoredTag(); - }); + $entry->hasMonitoredTag()); } /** @@ -56,10 +54,8 @@ protected function hideSensitiveRequestDetails(): void */ protected function gate(): void { - Gate::define('viewTelescope', function ($user) { - return in_array($user->email, [ + Gate::define('viewTelescope', fn ($user) => in_array($user->email, [ - ]); - }); + ])); } } diff --git a/tests/Feature/JoinSlackTest.php b/tests/Feature/JoinSlackTest.php index 48518d24..7994a7f4 100644 --- a/tests/Feature/JoinSlackTest.php +++ b/tests/Feature/JoinSlackTest.php @@ -29,12 +29,10 @@ public function test_a_user_can_submit_a_slack_request(): void Notification::assertSentTo( Notification::route('slack', config('services.slack.contact.webhook')), - function (JoinMessage $notification, array $channels) { - return $notification->contact === 'john@fake.email' + fn (JoinMessage $notification, array $channels) => $notification->contact === 'john@fake.email' && $notification->name === 'John Doe' && $notification->reason === 'I love Greenville!' - && $notification->url === 'https://linkedin.com/in/not-a-bot'; - } + && $notification->url === 'https://linkedin.com/in/not-a-bot' ); } } From 7ba84e9586d2fa97e89d336ebb764b8fe063f8f3 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Mon, 3 Feb 2025 22:15:44 -0500 Subject: [PATCH 7/7] Review --- app/Http/Controllers/CalendarFeedController.php | 6 ++++-- resources/views/calendar-feed/index.blade.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/CalendarFeedController.php b/app/Http/Controllers/CalendarFeedController.php index e548e7f1..e6ff2bb0 100644 --- a/app/Http/Controllers/CalendarFeedController.php +++ b/app/Http/Controllers/CalendarFeedController.php @@ -30,7 +30,9 @@ public function index() public function show(Request $request) { - $organization_ids = collect(explode('-', $request->input('orgs'))); + $organization_ids = collect(explode('-', $request->input('orgs'))) + ->take(150) // Only allow up to 150 orgs, could prevent unnecessary db lookups. + ->filter(fn ($id) => is_numeric($id) && (int) $id > 0); $organizations = Org::query() ->where('status', OrganizationStatus::Active) @@ -52,7 +54,7 @@ public function show(Request $request) default => EventStatus::confirmed(), }) ->address($event->venue?->fullAddress() ?? 'Virtual Event') - ->description($event->description) + ->description("Check out latest event details at {$event->url}") ->url($event->url), ]) ->toArray(); diff --git a/resources/views/calendar-feed/index.blade.php b/resources/views/calendar-feed/index.blade.php index 077914a4..60c5a3ff 100644 --- a/resources/views/calendar-feed/index.blade.php +++ b/resources/views/calendar-feed/index.blade.php @@ -1,7 +1,7 @@ @extends('layouts.app') @section('title', "Build a Calendar Feed of the events you're interested in") -@section('description', 'A monthly calendar view of upcoming tech events in the Greenville, SC area.') +@section('description', 'Generate an iCal calendar feed to pull events for one, many, or all organizations promoted by HackGreenville into your calendar app') @section('content')