From 7264be5e7810bdaa9f7b987e85ec9598b98a32e2 Mon Sep 17 00:00:00 2001 From: Mark van den Broek Date: Tue, 26 Nov 2024 13:06:08 +0100 Subject: [PATCH] save the floor price to database --- app/Jobs/CacheOrdinalsCollectionStats.php | 6 ++++++ tests/Unit/Jobs/CacheOrdinalsCollectionStatsTest.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/app/Jobs/CacheOrdinalsCollectionStats.php b/app/Jobs/CacheOrdinalsCollectionStats.php index 58d66b5..c8133d5 100644 --- a/app/Jobs/CacheOrdinalsCollectionStats.php +++ b/app/Jobs/CacheOrdinalsCollectionStats.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Models\FloorPrice; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; use Illuminate\Support\Facades\Cache; @@ -33,6 +34,11 @@ public function handle(): void if ($response->successful()) { Cache::put('ordinals_collection_stats_'.$this->symbol, $response->json()); + + $model = new FloorPrice; + $model->symbol = $response->json('symbol'); + $model->price_in_sats = $response->json('floorPrice'); + $model->save(); } } } diff --git a/tests/Unit/Jobs/CacheOrdinalsCollectionStatsTest.php b/tests/Unit/Jobs/CacheOrdinalsCollectionStatsTest.php index 37a1c84..864a459 100644 --- a/tests/Unit/Jobs/CacheOrdinalsCollectionStatsTest.php +++ b/tests/Unit/Jobs/CacheOrdinalsCollectionStatsTest.php @@ -3,6 +3,7 @@ namespace Tests\Unit\Jobs; use App\Jobs\CacheOrdinalsCollectionStats; +use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Http; use PHPUnit\Framework\Attributes\Test; @@ -10,6 +11,8 @@ class CacheOrdinalsCollectionStatsTest extends TestCase { + use RefreshDatabase; + protected function validResponse(): array { return [