diff --git a/app/Http/Controllers/CalendarFeedController.php b/app/Http/Controllers/CalendarFeedController.php index c813596d..f3af05e4 100644 --- a/app/Http/Controllers/CalendarFeedController.php +++ b/app/Http/Controllers/CalendarFeedController.php @@ -41,7 +41,7 @@ public function show(CalendarFeedRequest $request) { $events = Event::query() ->with('organization', 'venue') - ->future() + ->ongoingAndFuture() ->oldest('active_at') ->when($request->validOrganizations()->isNotEmpty(), fn ($query) => $query->whereIn('organization_id', $request->validOrganizations()->pluck('id'))) ->get() diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php index a3c5e121..6a36791f 100644 --- a/app/Http/Controllers/EventsController.php +++ b/app/Http/Controllers/EventsController.php @@ -8,7 +8,7 @@ class EventsController extends Controller { public function index() { - $months = Event::future() + $months = Event::ongoingAndFuture() ->published() ->with('organization', 'venue') ->orderBy('active_at') diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 258d32ad..89473c22 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -9,7 +9,7 @@ class HomeController extends Controller public function index() { return view('index', [ - 'upcoming_events' => Event::future() + 'upcoming_events' => Event::ongoingAndFuture() ->published() ->with('organization', 'venue') ->oldest('active_at') diff --git a/app/Http/Controllers/OrgsController.php b/app/Http/Controllers/OrgsController.php index 9c9778ba..8a9b0f33 100644 --- a/app/Http/Controllers/OrgsController.php +++ b/app/Http/Controllers/OrgsController.php @@ -27,7 +27,7 @@ public function show(Org $org) 'events' => function (Builder $query) { $query ->with('organization', 'venue') - ->future() + ->ongoingAndFuture() ->published() ->orderBy('active_at') ->limit(25); diff --git a/app/Models/Event.php b/app/Models/Event.php index 329b3bbd..878c7be7 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -63,6 +63,11 @@ public function scopeFuture(Builder $query): void $query->where('active_at', '>=', now()); } + public function scopeOngoingAndFuture(Builder $query): void + { + $query->where('expire_at', '>=', now()->startOfDay()); + } + public function url(): string { return $this->uri; diff --git a/resources/css/app.css b/resources/css/app.css index 8d4be8b4..20162453 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,4 +1,4 @@ -@import "tailwindcss"; +@import 'tailwindcss'; /* Migrate from tailwind.config.js theme.extend */ @theme { @@ -7,7 +7,9 @@ --color-warning: #de9d35; --color-danger: #f44336; - --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; + --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, + BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', + sans-serif; --breakpoint-nav-break: 1220px; } @@ -15,7 +17,7 @@ /* Preserve v3 button cursor behavior */ @layer base { button:not(:disabled), - [role="button"]:not(:disabled) { + [role='button']:not(:disabled) { cursor: pointer; } } diff --git a/resources/js/labs-hero.js b/resources/js/labs-hero.js index d12ca9c3..35c0da64 100644 --- a/resources/js/labs-hero.js +++ b/resources/js/labs-hero.js @@ -5,7 +5,9 @@ */ export function initHeroCanvas(canvas) { const ctx = canvas.getContext('2d'); - const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; + const prefersReducedMotion = window.matchMedia( + '(prefers-reduced-motion: reduce)', + ).matches; const PARTICLE_COUNT = 60; const CONNECT_DISTANCE = 120; @@ -55,7 +57,7 @@ export function initHeroCanvas(canvas) { const dy = p.y - mouse.y; const dist = Math.sqrt(dx * dx + dy * dy); if (dist < MOUSE_RADIUS && dist > 0) { - const force = (MOUSE_RADIUS - dist) / MOUSE_RADIUS * MOUSE_FORCE; + const force = ((MOUSE_RADIUS - dist) / MOUSE_RADIUS) * MOUSE_FORCE; p.vx += (dx / dist) * force; p.vy += (dy / dist) * force; } @@ -91,7 +93,9 @@ export function initHeroCanvas(canvas) { ctx.beginPath(); ctx.moveTo(p.x, p.y); ctx.lineTo(q.x, q.y); - ctx.strokeStyle = `rgba(255, 255, 255, ${0.15 * (1 - dist / CONNECT_DISTANCE)})`; + ctx.strokeStyle = `rgba(255, 255, 255, ${ + 0.15 * (1 - dist / CONNECT_DISTANCE) + })`; ctx.lineWidth = 0.5; ctx.stroke(); } diff --git a/tests/Feature/Http/Controllers/CalendarFeedTest.php b/tests/Feature/Http/Controllers/CalendarFeedTest.php index 42b790ed..1052552f 100644 --- a/tests/Feature/Http/Controllers/CalendarFeedTest.php +++ b/tests/Feature/Http/Controllers/CalendarFeedTest.php @@ -226,12 +226,11 @@ public function test_older_events_never_show_up_on_calendar_feed(): void $event = Event::factory()->create([ 'organization_id' => $organization->id, 'cancelled_at' => null, - 'active_at' => now()->subMinute(), - 'expire_at' => now()->subMinute(), + 'active_at' => now()->subWeek()->subMinute(), + 'expire_at' => now()->subWeek(), ]); $first_response = $this->get(route('calendar-feed.show', ['orgs' => $organization->id])); - preg_match('/UID:(.+)/', $first_response->getContent(), $first_match); $this->assertFalse(isset($first_match[1])); diff --git a/tests/Feature/Http/Controllers/HomeControllerTest.php b/tests/Feature/Http/Controllers/HomeControllerTest.php index e14a9cda..7059371d 100644 --- a/tests/Feature/Http/Controllers/HomeControllerTest.php +++ b/tests/Feature/Http/Controllers/HomeControllerTest.php @@ -20,14 +20,17 @@ public function test_upcoming_events_sorts_unordered_events() Event::factory()->create([ 'event_name' => 'Event 2', 'active_at' => '2020-01-01 19:00:00', + 'expire_at' => '2020-01-02 21:00:00', ]); Event::factory()->create([ 'event_name' => 'Event 1', 'active_at' => '2020-01-01 18:00:00', + 'expire_at' => '2020-01-02 20:00:00', ]); Event::factory()->create([ 'event_name' => 'Event 3', 'active_at' => '2020-01-02 12:00:00', + 'expire_at' => '2020-01-02 14:00:00', ]); $response = $this->get(route('home')); @@ -40,7 +43,8 @@ public function test_upcoming_events_does_not_show_old_events() { Event::factory()->create([ 'event_name' => 'Event 1', - 'active_at' => '2019-12-31 23:59:59', + 'active_at' => '2019-12-31 22:00:00', + 'expire_at' => '2019-12-31 23:00:00', ]); $response = $this->get(route('home')); diff --git a/tests/Feature/NoIndexNonProductionTest.php b/tests/Feature/NoIndexNonProductionTest.php index c51e191c..7b5a14c5 100644 --- a/tests/Feature/NoIndexNonProductionTest.php +++ b/tests/Feature/NoIndexNonProductionTest.php @@ -8,8 +8,7 @@ class NoIndexNonProductionTest extends TestCase { public function test_robots_txt_disallows_all_in_non_production(): void { - $this->assertEquals('testing', app()->environment()); - + $this->assertFalse(app()->isProduction()); $response = $this->get('/robots.txt'); $response->assertOk();