]> git.localhorst.tv Git - alttp.git/commitdiff
store hth handle for episodes
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 2 Feb 2026 13:06:58 +0000 (14:06 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 2 Feb 2026 13:06:58 +0000 (14:06 +0100)
app/Console/Commands/SyncHTH.php
app/Models/Episode.php
database/migrations/2026_02_02_121807_episode_ext_info.php [new file with mode: 0644]

index 1979c1defbefa03319f191ad019b01402407398a..310a5964b1507d9927878ad5cdf5debd8075b34b 100644 (file)
@@ -120,14 +120,14 @@ class SyncHTH extends Command {
                ])->throw()->json();
                foreach ($hthSchedule['data']['series']['event']['races'] as $hthEntry) {
                        try {
-                               $this->syncSchedule($event, $hthEntry);
+                               $this->syncSchedule($event, $hthHandle, $hthEntry);
                        } catch (\Exception $e) {
                                $this->error('error syncing episode '.$hthEntry['id'].': '.$e->getMessage());
                        }
                }
        }
 
-       private function syncSchedule(Event $event, $hthEntry): void {
+       private function syncSchedule(Event $event, $hthHandle, $hthEntry): void {
                $ext_id = 'hth:'.$hthEntry['id'];
                $episode = Episode::query()->firstWhere('ext_id', '=', $ext_id);
                if (!$hthEntry['start']) {
@@ -144,6 +144,7 @@ class SyncHTH extends Command {
                if (!$episode) {
                        $episode = new Episode();
                        $episode->ext_id = $ext_id;
+                       $episode->ext_info = ['handle' => $hthHandle];
                        $episode->estimate = 120 * 60;
                        $episode->confirmed = true;
                }
index 611a69c9103eb4faf2fba61eb7cb0491ab846b11..1ace6bd1a71425fa6b1f6b76c8c38b0b8fc800cf 100644 (file)
@@ -176,6 +176,7 @@ class Episode extends Model
                'confirmed' => 'boolean',
                'create_raceroom' => 'boolean',
                'do_not_restream' => 'boolean',
+               'ext_info' => 'array',
                'start' => 'datetime',
        ];
 
diff --git a/database/migrations/2026_02_02_121807_episode_ext_info.php b/database/migrations/2026_02_02_121807_episode_ext_info.php
new file mode 100644 (file)
index 0000000..51aef14
--- /dev/null
@@ -0,0 +1,28 @@
+<?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('episodes', function (Blueprint $table) {
+                       $table->text('ext_info')->default('{}')->after('ext_id');
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        */
+       public function down(): void
+       {
+               Schema::table('episodes', function (Blueprint $table) {
+                       $table->dropColumn('ext_info');
+               });
+       }
+};