Skip to content

Commit

Permalink
Only pull lat/lng from CallingAllPapers if location has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstauffer committed Dec 28, 2023
1 parent 318b3da commit 63f7a5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 5 additions & 4 deletions app/CallingAllPapers/ConferenceImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Carbon\Carbon;
use Carbon\Exceptions\InvalidFormatException;
use DateTime;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;

class ConferenceImporter
Expand Down Expand Up @@ -73,7 +72,6 @@ public function import(Event $event)
$this->updateConferenceFromCallingAllPapersEvent($conference, $event);

if (! $conference->latitude && ! $conference->longitude && $conference->location) {
Log::debug('Looking up geocode for conference ' . $conference->id . ' with location of ' . $conference->location);
$this->geocodeLatLongFromLocation($conference);
}

Expand All @@ -88,13 +86,16 @@ public function import(Event $event)

private function updateConferenceFromCallingAllPapersEvent(Conference $conference, Event $event)
{
if ($event->location != $conference->location) {
$conference->latitude = $this->nullifyInvalidLatLong($event->latitude, $event->longitude);
$conference->longitude = $this->nullifyInvalidLatLong($event->longitude, $event->latitude);
}

$conference->title = trim($event->name);
$conference->description = trim($event->description);
$conference->url = trim($event->eventUri);
$conference->cfp_url = $event->uri;
$conference->location = $event->location;
$conference->latitude = $this->nullifyInvalidLatLong($event->latitude, $event->longitude);
$conference->longitude = $this->nullifyInvalidLatLong($event->longitude, $event->latitude);
$conference->starts_at = $event->dateEventStart;
$conference->ends_at = $event->dateEventEnd;
$conference->cfp_starts_at = $event->dateCfpStart;
Expand Down
2 changes: 0 additions & 2 deletions app/Services/Geocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Casts\Coordinates;
use App\Exceptions\InvalidAddressGeocodingException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class Geocoder
{
Expand All @@ -18,7 +17,6 @@ public function geocode(string $address): Coordinates
$response = $this->requestGeocoding($address);

if (! count($response['results'])) {
Log::debug('Caching address as invalid: [' . $address . ']');
cache()->set('invalid-address::' . md5($address), true);
throw new InvalidAddressGeocodingException();
}
Expand Down

0 comments on commit 63f7a5f

Please sign in to comment.