Skip to content

Commit

Permalink
Merge branch 'master' of github.com:maelstrom-cms/odin
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenMelbz committed May 19, 2020
2 parents a428f58 + a62b260 commit 1ab80bd
Show file tree
Hide file tree
Showing 13 changed files with 1,457 additions and 1,032 deletions.
5 changes: 4 additions & 1 deletion app/Checkers/Certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ private function fetch()
'valid_to' => $certificate->expirationDate(),
'was_valid' => $certificate->isValid(),
'did_expire' => $certificate->isExpired(),
'grade' => 'N/A',
]);

$this->website->certificates()->save($scan);

$labs = new SslLabs();

$result = $labs->analyze(
Expand All @@ -58,7 +61,7 @@ private function fetch()
foreach ($result->endpoints ?? [] as $endpoint) {
if ($endpoint->statusMessage === 'Ready') {
$scan->grade = $endpoint->grade;
$this->website->certificates()->save($scan);
$scan->save();
$this->scan = $scan;
break;
}
Expand Down
8 changes: 7 additions & 1 deletion app/HasUptime.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,18 @@ public function getRecentEventsAttribute()
public function getTimeSpentOfflineAttribute()
{
$events = $this->recent_events;
$lastEvent = $events->first();

if ($lastEvent['state'] !== 'up') {
return now()->diffAsCarbonInterval($lastEvent['date'])->forHumans(['join' => true]);
}

$downEvent = $events->firstWhere('state', 'down');

if (!$downEvent) {
return 'Unknown...';
}

return $downEvent['duration'];
return $lastEvent['date']->diffAsCarbonInterval($downEvent['date'])->forHumans(['join' => true]);
}
}
8 changes: 4 additions & 4 deletions app/Http/Controllers/ProblematicPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace App\Http\Controllers;

use Exception;
use App\Website;
use App\CrawledPage;
use App\Jobs\PageCheck;
use App\Website;
use Exception;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Contracts\Routing\ResponseFactory;

class ProblematicPageController extends Controller
{
Expand All @@ -27,7 +27,7 @@ public function __invoke(Request $request, Website $website)

$count = $query->count();

if ($request->input('refresh',)) {
if ($request->input('refresh')) {
cache()->forget('pages_' . $website->id);
}

Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/WebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function __construct()
'name' => 'url',
'label' => 'Website',
'type' => 'EditLinkColumn',
'searchable' => true,
'searchColumn' => 'url',
],
[
'name' => 'ssl_enabled',
Expand Down Expand Up @@ -189,7 +191,7 @@ public function destroy(Website $website)

$this->panel->destroy('Website removed.');

Artisan::call('horizon:terminate');
// Artisan::call('horizon:terminate');

return $this->panel->redirect('index');
}
Expand Down
9 changes: 9 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace App\Providers;

use App\Website;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Schema;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -26,5 +28,12 @@ public function register()
public function boot()
{
Schema::defaultStringLength(191);

Queue::failing(function (JobFailed $event) {
logger()->error('job failed', [$event]);
// $event->connectionName
// $event->job
// $event->exception
});
}
}
Loading

0 comments on commit 1ab80bd

Please sign in to comment.