Skip to content

Commit

Permalink
save the floor price to database
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdnbrk committed Nov 26, 2024
1 parent 5ceafdd commit 7264be5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Jobs/CacheOrdinalsCollectionStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
3 changes: 3 additions & 0 deletions tests/Unit/Jobs/CacheOrdinalsCollectionStatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
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;
use Tests\TestCase;

class CacheOrdinalsCollectionStatsTest extends TestCase
{
use RefreshDatabase;

protected function validResponse(): array
{
return [
Expand Down

0 comments on commit 7264be5

Please sign in to comment.