Skip to content

Commit

Permalink
Merge branch 'dev' into filament
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.lock
  • Loading branch information
arthurpar06 committed Feb 14, 2024
2 parents 7888f98 + cea90aa commit 35d1552
Show file tree
Hide file tree
Showing 20 changed files with 704 additions and 231 deletions.
6 changes: 3 additions & 3 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ protected function schedule(Schedule $schedule): void

// When spatie-backups runs
if (config('backup.backup.enabled', false) === true) {
$schedule->command(BackupRun::class)->daily()->at('01:10');
$schedule->command(BackupClean::class)->daily()->at('01:20');
$schedule->command(BackupMonitor::class)->daily()->at('01:30');
$schedule->command(BackupRun::class)->dailyAt('01:15');
$schedule->command(BackupClean::class)->dailyAt('01:30');
$schedule->command(BackupMonitor::class)->dailyAt('01:45');
}

// Update the last time the cron was run
Expand Down
1 change: 1 addition & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class User extends Authenticatable implements MustVerifyEmail, FilamentUser, Has
public $sortable = [
'id',
'name',
'email',
'pilot_id',
'callsign',
'country',
Expand Down
4 changes: 4 additions & 0 deletions app/Notifications/Channels/Discord/DiscordMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ public function toArray(): array
'timestamp' => Carbon::now('UTC'),
];

if (empty($embeds['thumbnail'])) {
unset($embeds['thumbnail']);
}

if (empty($embeds['image'])) {
unset($embeds['image']);
}
Expand Down
5 changes: 4 additions & 1 deletion app/Services/FlightService.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ public function isFlightDuplicate(Flight $flight)
// If this list is > 0, then this has a duplicate
$found_flights = $found_flights->filter(function ($value, $key) use ($flight) {
return $flight->route_code === $value->route_code
&& $flight->route_leg === $value->route_leg;
&& $flight->route_leg === $value->route_leg
&& $flight->dpt_airport_id === $value->dpt_airport_id
&& $flight->arr_airport_id === $value->arr_airport_id
&& $flight->days === $value->days;
});

return !($found_flights->count() === 0);
Expand Down
63 changes: 8 additions & 55 deletions app/Services/Metar/AviationWeather.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
use Exception;
use Illuminate\Support\Facades\Log;

use function count;

/**
* Return the raw METAR/TAF string from the NOAA Aviation Weather Service
*/
class AviationWeather extends Metar
{
private const METAR_URL = 'https://aviationweather.gov/cgi-bin/data/dataserver.php?requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&dataSource=metars&stationString=';
private const METAR_URL = 'https://aviationweather.gov/api/data/metar?ids=';

private const TAF_URL = 'https://aviationweather.gov/cgi-bin/data/dataserver.php?requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&dataSource=tafs&stationString=';
private const TAF_URL = 'https://aviationweather.gov/api/data/taf?ids=';

/**
* @param HttpClient $httpClient
Expand Down Expand Up @@ -45,33 +43,8 @@ protected function get_metar($icao): string
$url = static::METAR_URL.$icao;

try {
$res = $this->httpClient->get($url, []);
$xml = simplexml_load_string($res);

if ($xml->errors && count($xml->errors->children()) > 0) {
return '';
}

$attrs = $xml->data->attributes();
if (!isset($attrs['num_results'])) {
return '';
}

$num_results = $attrs['num_results'];
if (empty($num_results)) {
return '';
}

$num_results = (int) $num_results;
if ($num_results === 0) {
return '';
}

if (count($xml->data->METAR->raw_text) === 0) {
return '';
}

return $xml->data->METAR->raw_text->__toString();
$raw_metar = $this->httpClient->get($url);
return trim($raw_metar);
} catch (Exception $e) {
Log::error('Error reading METAR: '.$e->getMessage());
return '';
Expand All @@ -93,32 +66,12 @@ protected function get_taf($icao): string
return '';
}

$tafurl = static::TAF_URL.$icao;
$url = static::TAF_URL.$icao;

try {
$tafres = $this->httpClient->get($tafurl, []);
$tafxml = simplexml_load_string($tafres);

$tafattrs = $tafxml->data->attributes();
if (!isset($tafattrs['num_results'])) {
return '';
}

$tafnum_results = $tafattrs['num_results'];
if (empty($tafnum_results)) {
return '';
}

$tafnum_results = (int) $tafnum_results;
if ($tafnum_results === 0) {
return '';
}

if (count($tafxml->data->TAF->raw_text) === 0) {
return '';
}

return $tafxml->data->TAF->raw_text->__toString();
$raw_taf = $this->httpClient->get($url);
// Remove " \n" to remove new lines from the metar content
return trim(str_replace(" \n", '', $raw_taf));
} catch (Exception $e) {
Log::error('Error reading TAF: '.$e->getMessage());
return '';
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
"laravel/socialite": "^5.11",
"socialiteproviders/discord": "^4.2",
"symfony/postmark-mailer": "^6.0",
"league/html-to-markdown": "^5.1"
"league/html-to-markdown": "^5.1",
"league/flysystem-aws-s3-v3": "^3.0",
"league/flysystem-sftp-v3": "^3.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.8.1",
Expand Down
Loading

0 comments on commit 35d1552

Please sign in to comment.