From ca02f21812792f62543219d1066dda1034604823 Mon Sep 17 00:00:00 2001 From: shibafu <shibafu528@gmail.com> Date: Fri, 11 Jan 2019 22:38:43 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E6=99=82=E3=81=AE=E3=83=A1=E3=82=BF=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=82=BF=E5=8F=96=E5=BE=97=E3=81=AB=E5=A4=B1=E6=95=97?= =?UTF-8?q?=E3=81=97=E3=81=9F=E9=9A=9B=E3=80=81=E3=83=AD=E3=82=B0=E3=81=A0?= =?UTF-8?q?=E3=81=91=E6=AE=8B=E3=81=97=E3=81=A6=E7=B5=82=E4=BA=86=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Listeners/LinkCollector.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Listeners/LinkCollector.php b/app/Listeners/LinkCollector.php index 6bd41ad..3d34b89 100644 --- a/app/Listeners/LinkCollector.php +++ b/app/Listeners/LinkCollector.php @@ -6,8 +6,10 @@ use App\Events\LinkDiscovered; use App\Metadata; use App\MetadataResolver\MetadataResolver; use App\Utilities\Formatter; +use GuzzleHttp\Exception\TransferException; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Support\Facades\Log; class LinkCollector { @@ -42,13 +44,19 @@ class LinkCollector // TODO: ある程度古かったら再取得とかありだと思う $metadata = Metadata::find($url); if ($metadata == null) { - $resolved = $this->metadataResolver->resolve($url); - Metadata::create([ - 'url' => $url, - 'title' => $resolved->title, - 'description' => $resolved->description, - 'image' => $resolved->image - ]); + try { + $resolved = $this->metadataResolver->resolve($url); + Metadata::create([ + 'url' => $url, + 'title' => $resolved->title, + 'description' => $resolved->description, + 'image' => $resolved->image + ]); + } catch (TransferException $e) { + // 何らかの通信エラーによってメタデータの取得に失敗した時、とりあえずエラーログにURLを残す + Log::error(self::class . ': メタデータの取得に失敗 URL=' . $url); + report($e); + } } } } From 20799dd757a11e1abd6fc97c2bffb8df77b2ba4f Mon Sep 17 00:00:00 2001 From: shibafu <shibafu528@gmail.com> Date: Sat, 12 Jan 2019 00:14:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=81=8A=E6=83=A3=E8=8F=9C=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=8A=E3=83=BC=E3=81=AE=E8=A1=A8=E7=A4=BA=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E3=82=92=E5=B0=91=E3=81=97=E5=A2=97=E3=82=84=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/HomeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 4d655e8..a5b257d 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -44,7 +44,7 @@ class HomeController extends Controller ->orderBy('ejaculations.ejaculated_date', 'desc') ->select('ejaculations.*') ->with('user', 'tags') - ->take(5) + ->take(10) ->get(); return view('home')->with(compact('informations', 'categories', 'publicLinkedEjaculations'));