]> git.localhorst.tv Git - alttp.git/commitdiff
remove coop zossy sync
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 9 Aug 2025 21:48:12 +0000 (23:48 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 9 Aug 2025 21:48:12 +0000 (23:48 +0200)
google sheets public views are JS now Sadge

app/Console/Commands/SyncCoopZossy.php [deleted file]
routes/console.php

diff --git a/app/Console/Commands/SyncCoopZossy.php b/app/Console/Commands/SyncCoopZossy.php
deleted file mode 100644 (file)
index 4216678..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Models\Episode;
-use App\Models\EpisodePlayer;
-use App\Models\Event;
-use App\Models\User;
-use Carbon\Carbon;
-use Illuminate\Console\Command;
-use Illuminate\Database\Eloquent\Builder;
-use Illuminate\Support\Facades\Http;
-
-class SyncCoopZossy extends Command {
-
-       /**
-        * The name and signature of the console command.
-        *
-        * @var string
-        */
-       protected $signature = 'sync:coop-zossy';
-
-       /**
-        * The console command description.
-        *
-        * @var string
-        */
-       protected $description = 'Synchronize Co-op Crosskeys schedule';
-
-       /**
-        * Execute the console command.
-        *
-        * @return int
-        */
-       public function handle(): int {
-               $events = Event::where('external_schedule', '=', 'coop-zossy')
-                       ->where(function (Builder $query) {
-                               $query->whereNull('end');
-                               $query->orWhere('end', '>', now());
-                       })
-                       ->get();
-
-               if (empty($events)) {
-                       return Command::SUCCESS;
-               }
-
-               $html = Http::get('https://docs.google.com/spreadsheets/d/e/2PACX-1vQhNJzwr2pOJsbVcLtfxOS3Jg8xb0h05vGJAd1vXhCRXXFjVbju6L8uK2cHlJKhCsPyBvuqOJFZ2Ext/pubhtml?gid=&single=true', [
-                       'gid' => '377832929',
-                       'single' => 'true',
-               ])->body();
-               $dom = new \DOMDocument();
-               $dom->loadHTML($html);
-               $rows = $dom->getElementsByTagName('tr');
-               $schedule = [];
-               foreach ($rows as $row) {
-                       $cells = $row->getElementsByTagName('td');
-                       $entry = [];
-                       foreach ($cells as $cell) {
-                               $entry[] = $cell->textContent;
-                       }
-                       $schedule[] = $entry;
-               }
-
-               foreach ($events as $event) {
-                       try {
-                               $this->line('syncing '.$event->name);
-                               $this->syncEvent($event, $schedule);
-                       } catch (\Exception $e) {
-                               $this->error('error syncing event '.$event->name.': '.$e->getMessage());
-                       }
-               }
-
-               return Command::SUCCESS;
-       }
-
-       private function syncEvent(Event $event, $schedule) {
-               for ($i = 3; $i < count($schedule); ++$i) {
-                       $this->syncSchedule($event, $schedule[$i]);
-               }
-       }
-
-       private function syncSchedule(Event $event, $row) {
-               if (empty($row[3])) {
-                       return;
-               }
-               $ext_id = 'coop-zossy:'.$event->id.':'.$row[0];
-               $episode = Episode::firstWhere('ext_id', '=', $ext_id);
-               if ($row[3] == 'TBD') {
-                       if ($episode) {
-                               $this->line('calling off'.$row[0]);
-                               $episode->callOff();
-                               $episode->delete();
-                       }
-                       return;
-               }
-               if (!$episode) {
-                       $episode = new Episode();
-                       $episode->ext_id = $ext_id;
-               }
-               $episode->event()->associate($event);
-               $episode->title = $row[0];
-               $start = Carbon::createFromFormat('D M d, Y h:i A \\E\\T', $row[3], 'America/Detroit')->setTimezone('UTC');
-               if (!$episode->start || $start->ne($episode->start)) {
-                       $episode->start = $start;
-               }
-               $episode->estimate = 120 * 60;
-               $episode->confirmed = true;
-               $episode->save();
-
-               $this->line($row[0]);
-               $this->line(' - '.$row[1]);
-               $this->line(' - '.$row[2]);
-
-               $playersA = explode(' and ', $row[1]);
-               $playersB = explode(' and ', $row[2]);
-               $this->syncPlayer($episode, $playersA[0]);
-               $this->syncPlayer($episode, $playersB[0]);
-               $this->syncPlayer($episode, $playersA[1]);
-               $this->syncPlayer($episode, $playersB[1]);
-       }
-
-       private function syncPlayer(Episode $episode, $codename) {
-               $lower_name = strtolower($codename);
-               $ext_id = 'coop-zossy:'.$lower_name;
-               $player = $episode->players()->firstWhere('ext_id', '=', $ext_id);
-               if (!$player) {
-                       $player = new EpisodePlayer();
-                       $player->ext_id = $ext_id;
-                       $player->episode()->associate($episode);
-               }
-               $player->name_override = $codename;
-               $user = $this->getUser($lower_name);
-               if ($user) {
-                       $player->user()->associate($user);
-               } else {
-                       $player->user()->disassociate();
-               }
-               $player->save();
-               return $player;
-       }
-
-       private function getUser($codename) {
-               if (isset($this->codename_table[$codename])) {
-                       $user = User::firstWhere('username', 'LIKE', $this->codename_table[$codename]);
-                       if ($user) {
-                               return $user;
-                       }
-               }
-               $user = User::firstWhere('discord_nickname', 'LIKE', $codename);
-               if ($user) {
-                       return $user;
-               }
-               $user = User::firstWhere('username', 'LIKE', $codename);
-               if ($user) {
-                       return $user;
-               }
-               $user = User::firstWhere('stream_link', 'LIKE', '%/'.$codename);
-               if ($user) {
-                       return $user;
-               }
-               return null;
-       }
-
-       private $codename_table = [
-               'doctor-marty-0' => 'doctor_marty_0',
-               'echo' => 'echo6921',
-               'eris' => 'erisbtw',
-               'g1rd0' => 'thalane',
-               'g2rd0' => 'jem041',
-               'jamo' => 'jamo6',
-               'leaf' => 'windblownleaf',
-               'magnit handz' => 'magnithandz',
-               'magno' => 'magnohato',
-               'mrangrypants' => 'misterangrypants',
-               'nick' => 'humbugh',
-               'nobly' => 'noblytheforeign',
-               'teto' => '.teto',
-               'the cage' => 'telethar',
-               'trey spyre' => 'treyspyre',
-       ];
-
-}
index 41ca0c60caff91e3f97fe5f9768052c9e1b28808..f8a2c3627e4633784711b3362fd4cdd507c51e5f 100644 (file)
@@ -22,7 +22,6 @@ Schedule::everyFiveMinutes()
        ->group(function () {
                Schedule::command('sync:speedgaming');
                Schedule::command('sync:cabookey');
-               Schedule::command('sync:coop-zossy');
                Schedule::command('sync:enemizer');
                Schedule::command('sync:hth');
                Schedule::command('sync:nmg-league');