-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get weather from weatherapi (#5668)
- Loading branch information
Showing
20 changed files
with
473 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use RuntimeException; | ||
|
||
class NoCoordinatesException extends RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Models\Account\Place; | ||
use Illuminate\Bus\Batchable; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use App\Exceptions\NoCoordinatesException; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use App\Services\Instance\Weather\GetWeatherInformation as GetWeatherInformationService; | ||
|
||
class GetWeatherInformation implements ShouldQueue | ||
{ | ||
use Batchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
/** | ||
* @var Place | ||
*/ | ||
protected $place; | ||
|
||
/** | ||
* The number of times the job may be attempted. | ||
* | ||
* @var int | ||
*/ | ||
public $tries = 10; | ||
|
||
/** | ||
* The maximum number of unhandled exceptions to allow before failing. | ||
* | ||
* @var int | ||
*/ | ||
public $maxExceptions = 1; | ||
|
||
/** | ||
* Create a new job instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Place $place) | ||
{ | ||
$this->place = $place->withoutRelations(); | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
if (! $this->batching()) { | ||
return; | ||
} | ||
|
||
if (is_null($this->place->latitude)) { | ||
$this->fail(new NoCoordinatesException()); | ||
} else { | ||
app(GetWeatherInformationService::class)->execute([ | ||
'account_id' => $this->place->account_id, | ||
'place_id' => $this->place->id, | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.