refactor: split oil price ingestion and prediction into separate services + commands

- BrentPriceFetcher owns ingestion (fetchFromEia / fetchFromFred, each throws on failure)
- BrentPricePredictor owns prediction and marks latest brent_prices row as generated
- oil:fetch command tries EIA, falls back to FRED, fails loudly if both fail
- oil:predict command prompts if latest price already has a prediction; --force bypasses
- add prediction_generated_at column to brent_prices
- delete OilPriceService (replaced by the two focused services)
This commit is contained in:
Ovidiu U
2026-04-14 16:59:43 +01:00
parent 1a0381265e
commit 486f0e689c
10 changed files with 415 additions and 306 deletions

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('brent_prices', function (Blueprint $table) {
$table->timestamp('prediction_generated_at')->nullable()->after('price_usd');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('brent_prices', function (Blueprint $table) {
$table->dropColumn('prediction_generated_at');
});
}
};