diff --git a/scripts/update_everything.sh b/scripts/update_everything.sh index ce6f94f..4c7816a 100644 --- a/scripts/update_everything.sh +++ b/scripts/update_everything.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash # import all fighters. -drush @self.local ev '\Drupal::service("ufc.importer")->importFighters()'; ddev drush @self.local ev '\Drupal::service("ufc.import_fighters")->importFighters();'; ddev drush @self.local ev '\Drupal::service("ufc.import_fights")->importEvents();'; -ddev drush @self.local ev '\Drupal::service("ufc.import_fights")->createEvents();'; +ddev drush @self.local ev '\Drupal::service("ufc.import_fights")->createFights();'; diff --git a/web/modules/custom/ufc/src/Fighter.php b/web/modules/custom/ufc/src/Fighter.php index 8b065c6..eaf3a3f 100644 --- a/web/modules/custom/ufc/src/Fighter.php +++ b/web/modules/custom/ufc/src/Fighter.php @@ -186,7 +186,13 @@ public function setFighterRecord(): void { */ public function setAccuracy(): void { $circles = $this->crawler->filter('.e-chart-circle'); + if (empty($circles)) { + return; + } foreach ($circles as $circle) { + if (is_null($circle)) { + continue; + } foreach ($circle->childNodes as $child) { $text = strtolower($child->textContent); if (str_contains($text, "accuracy")) { diff --git a/web/modules/custom/ufc/src/Services/FighterImporter.php b/web/modules/custom/ufc/src/Services/FighterImporter.php index 38698f9..dbc73ba 100644 --- a/web/modules/custom/ufc/src/Services/FighterImporter.php +++ b/web/modules/custom/ufc/src/Services/FighterImporter.php @@ -174,8 +174,8 @@ public function loopThroughFighterPages($base_url): void { /* $cid = "ufc:" . $url; */ $request = $this->httpClient->request('GET', $url, $headers); $content = $request->getBody()->getContents(); - $check = strpos($content, "No Result Found For"); - if (!$check) { + $invalid_page = strpos($content, "No Result Found For"); + if (!$invalid_page) { \Drupal::logger('ufc')->notice("Extracting fighters from page $i."); self::extractFighters($content); continue;