mempool weather added

This commit is contained in:
HolgerHatGarKeineNode
2023-04-01 10:06:15 +02:00
parent 52da742d66
commit 4df2074477
2 changed files with 33 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Console\Commands\MempoolSpace;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use OpenAI; use OpenAI;
class CacheRecommendedFees extends Command class CacheRecommendedFees extends Command
@@ -25,6 +26,7 @@ class CacheRecommendedFees extends Command
*/ */
public function handle(): void public function handle(): void
{ {
try {
$apiKey = config('services.open-ai.apiKey'); $apiKey = config('services.open-ai.apiKey');
$client = OpenAI::client($apiKey); $client = OpenAI::client($apiKey);
@@ -47,5 +49,8 @@ class CacheRecommendedFees extends Command
cache()->put('mempool-weather', $result['choices'][0]['text'], now()->addMinutes(62)); cache()->put('mempool-weather', $result['choices'][0]['text'], now()->addMinutes(62));
cache()->put('mempool-weather-changed', now()->toDateTimeString(), now()->addMinutes(62)); cache()->put('mempool-weather-changed', now()->toDateTimeString(), now()->addMinutes(62));
} catch (\Exception $exception) {
Log::error($exception->getMessage());
}
} }
} }

View File

@@ -32,9 +32,15 @@
Blockhöhe <span class="font-bold text-2xl ml-4" x-text="height && height.toLocaleString('de-DE')"></span> Blockhöhe <span class="font-bold text-2xl ml-4" x-text="height && height.toLocaleString('de-DE')"></span>
</span> </span>
</div> </div>
@if(!empty($weather))
<div class="text-md leading-6 text-gray-900 text-center max-w-screen-2xl"> <div class="text-md leading-6 text-gray-900 text-center max-w-screen-2xl">
{{ $weather }} (um {{ \App\Support\Carbon::parse($changed)->asTime() }} Uhr aktualisiert - stündlich) {{ $weather }} (um {{ \App\Support\Carbon::parse($changed)->asTime() }} Uhr aktualisiert - stündlich)
</div> </div>
@else
<div class="text-md leading-6 text-gray-900 text-center max-w-screen-2xl">
Wetterdaten werden in Kürze wieder verfügbar sein. (OpenAI Quota exceeded)
</div>
@endif
<div <div
x-data="{ x-data="{
fastestFee: null, fastestFee: null,