Skip to content

Commit

Permalink
Last checks will now return time in diff for humans
Browse files Browse the repository at this point in the history
  • Loading branch information
jonassiewertsen committed Mar 6, 2020
1 parent 96ebc44 commit cb97c19
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion resources/views/overview/_broken_links.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
@slot('link_url')
{{ cp_route('oh-dear.broken-links') }}
@endslot
{{ __('oh-dear::lang.broken_links_success_message', ['time' => 'something']) }}
{{ __('oh-dear::lang.broken_links_success_message', ['time' => $checks['broken_links']['latest_run']]) }}
@endcomponent
2 changes: 1 addition & 1 deletion resources/views/overview/_certificate.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
@slot('link_url')
{{ cp_route('oh-dear.certificate-health') }}
@endslot
{{ __('oh-dear::lang.certificate_health_success_message', ['time' => 'something']) }}
{{ __('oh-dear::lang.certificate_health_success_message', ['time' => $checks['certificate']['latest_run']]) }}
@endcomponent
2 changes: 1 addition & 1 deletion resources/views/overview/_mixed_content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
@slot('link_url')
{{ cp_route('oh-dear.mixed-content') }}
@endslot
{{ __('oh-dear::lang.mixed_content_success_message', ['time' => 'something']) }}
{{ __('oh-dear::lang.mixed_content_success_message', ['time' => $checks['mixed_content']['latest_run']]) }}
@endcomponent
2 changes: 1 addition & 1 deletion resources/views/overview/_uptime.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
@slot('link_url')
{{ cp_route('oh-dear.uptime') }}
@endslot
{{ __('oh-dear::lang.uptime_success_message', ['time' => 'something']) }}
{{ __('oh-dear::lang.uptime_success_message', ['time' => $checks['uptime']['latest_run']]) }}
@endcomponent
21 changes: 17 additions & 4 deletions src/OhDear.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function uptimeCheck() {
$uptime = collect($this->site->checks)
->where('type', 'uptime');

return $uptime->first()->attributes;
return $this->addLastRun($uptime->first()->attributes);
}

/**
Expand All @@ -154,7 +154,7 @@ public function brokenLinksCheck() {
$links = collect($this->site->checks)
->where('type', 'broken_links');

return $links->first()->attributes;
return $this->addLastRun($links->first()->attributes);
}

/**
Expand All @@ -166,7 +166,7 @@ public function mixedContentCheck() {
$contents = collect($this->site->checks)
->where('type', 'mixed_content');

return $contents->first()->attributes;
return $this->addLastRun($contents->first()->attributes);
}

/**
Expand All @@ -178,6 +178,19 @@ public function certificateCheck() {
$certificate = collect($this->site->checks)
->where('type', 'certificate_health');

return $certificate->first()->attributes;
return $this->addLastRun($certificate->first()->attributes);
}

/**
* Adding the last run in diff for human string
*
* @param $attributes
* @return array
*/
private function addLastRun($attributes) {
return array_merge(
$attributes,
['latest_run' => Carbon::parse($attributes['latest_run_ended_at'])->diffForHumans()]
);
}
}

0 comments on commit cb97c19

Please sign in to comment.