]> git.localhorst.tv Git - alttp.git/commitdiff
raceroom creation flag & lead time setting
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 8 Dec 2025 14:12:18 +0000 (15:12 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 8 Dec 2025 14:12:18 +0000 (15:12 +0100)
app/Http/Controllers/EpisodeController.php
app/Models/Episode.php
app/Models/Event.php
database/migrations/2025_12_08_124710_raceroom_creation_flags.php [new file with mode: 0644]
docs/public-api.md

index c2d9cc809df5df9a5b28dbcebd5731cd99471ca7..9711849c50d8f669351e0f7a7242d3519a70ae51 100644 (file)
@@ -224,6 +224,7 @@ class EpisodeController extends Controller {
                $validatedData = $request->validate([
                        'after' => 'nullable|date',
                        'before' => 'nullable|date',
+                       'create_raceroom' => 'boolean',
                        'event' => 'nullable|array',
                        'event.*' => 'numeric',
                        'eventInvert' => 'boolean',
@@ -249,6 +250,13 @@ class EpisodeController extends Controller {
                if (isset($validatedData['before'])) {
                        $episodes = $episodes->where('episodes.start', '<=', $validatedData['before']);
                }
+               if (isset($validatedData['create_raceroom'])) {
+                       if ($validatedData['create_raceroom']) {
+                               $episodes->where(DB::raw('COALESCE(`episodes`.`create_raceroom`, `events`.`create_raceroom`)'), '!=', '0');
+                       } else {
+                               $episodes->where(DB::raw('COALESCE(`episodes`.`create_raceroom`, `events`.`create_raceroom`)'), '=', '0');
+                       }
+               }
                if (!$this->userMaySeeAllEvents($request)) {
                        $privIDs = $this->getUserPrivilegedEvents($request);
                        if (!empty($privIDs)) {
index d60fd630e033d9c99b3151aae0ff79420f87837c..67114c78cf84d0687f5dbc28bbac047bc55802d7 100644 (file)
@@ -174,6 +174,7 @@ class Episode extends Model
 
        protected $casts = [
                'confirmed' => 'boolean',
+               'create_raceroom' => 'boolean',
                'start' => 'datetime',
        ];
 
index 83caeadec8ed7ae0f1ac607c808cca853b5dc6b3..8a0d198f26562469fffa91810081265016b34afa 100644 (file)
@@ -41,6 +41,7 @@ class Event extends Model
        }
 
        protected $casts = [
+               'create_raceroom' => 'boolean',
                'end' => 'datetime',
                'start' => 'datetime',
                'visible' => 'boolean',
diff --git a/database/migrations/2025_12_08_124710_raceroom_creation_flags.php b/database/migrations/2025_12_08_124710_raceroom_creation_flags.php
new file mode 100644 (file)
index 0000000..0f44d18
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        */
+       public function up(): void
+       {
+               Schema::table('events', function (Blueprint $table) {
+                       $table->boolean('create_raceroom')->default(false);
+                       $table->unsignedInteger('raceroom_lead_time')->default(30 * 60);
+               });
+               Schema::table('episodes', function (Blueprint $table) {
+                       $table->string('create_raceroom')->nullable()->default(null);
+                       $table->string('raceroom_lead_time')->nullable()->default(null);
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        */
+       public function down(): void
+       {
+               Schema::table('events', function (Blueprint $table) {
+                       $table->dropColumn('create_raceroom');
+                       $table->dropColumn('raceroom_lead_time');
+               });
+               Schema::table('episodes', function (Blueprint $table) {
+                       $table->dropColumn('create_raceroom');
+                       $table->dropColumn('raceroom_lead_time');
+               });
+       }
+};
index eb07312f579aedb9caa7b6c8298c08347ea1532e..faddadc4f0ad519c4a4322c4e24a35147a041b06 100644 (file)
@@ -1,5 +1,14 @@
 # Public API
 
+GET parameters:
+multivalued parameters use the PHP bracket notation, e.g. event%5B%5D=2&event%5B%5D=5
+datetime values use ISO notation, e.g. 2025-10-16T22:00:00.000000Z
+booleans are encoded as "0" or "1"
+
+Responses:
+200 Responses will have a JSON encoded Object or Array as body
+other responses will communicate their intent via status code, most will also have boilerplate HTML bodies
+
 ## Base URI
 
 https://alttp.localhorst.tv/api
@@ -14,6 +23,7 @@ GET /episodes
 Parameters:
 - after: Date
 - before: Date
+- create_raceroom: Boolean
 - event[]: Integer
 - eventInvert: Boolean; switches event[] to exclusion filter
 - game[]: String
@@ -26,6 +36,7 @@ Response: Array of Episode objects with following fields:
 - channels: Array of Channel objects
 - comment: String; supplementary information, may be empty, not localised
 - confirmed: Boolean
+- create_raceroom: Boolean or null; if null, use event's prop instead
 - crew: Array of EpisodeCrew objects
 - estimate: Integer; approximate runtime in seconds
 - event: Object of type Event
@@ -34,6 +45,7 @@ Response: Array of Episode objects with following fields:
 - id: Integer
 - players: Array of EpisodePlayer objects; with user if available
 - raceroom: String or null; URL of race room if available
+- raceroom_lead_time: Integer or null; in seconds. if null, use event's prop instead
 - start: Date; includes delay, if any
 - title: String
 
@@ -87,12 +99,14 @@ Parameters:
 Response: Array of Event objects with following fields:
 - banner: String; host-relative URL to banner image (discord event layout) or empty
 - corner: String; host-relative URL to corner image (bottom left background) or empty
+- create_raceroom: Boolean
 - description: optional object of type Content or null; only present if with[]=description was requested, may be null if event has no description
 - end: Date or null
 - external_schedule: String or null; if externally managed, this contains the reference
 - game: String or null
 - id: Integer
 - name: String
+- raceroom_lead_time: Integer; in seconds
 - racetime_category: String or null
 - short: String; shorter version of title, may be empty
 - start: Date or null