feat(history): add energy price history feature
This commit is contained in:
@@ -4,8 +4,9 @@ namespace App\Repositories;
|
||||
|
||||
use App\Contracts\PriceClient;
|
||||
use App\Contracts\PriceRepository as ContractsPriceRepository;
|
||||
use App\Features\Dashboard\Data\ElectricityData;
|
||||
use App\Features\Dashboard\Data\GasData;
|
||||
use App\Data\ElectricityData;
|
||||
use App\Data\GasData;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Override;
|
||||
@@ -19,16 +20,32 @@ class ZonneplanPriceRepository implements ContractsPriceRepository
|
||||
#[Override]
|
||||
public function retrieveElectricity(): Collection
|
||||
{
|
||||
$data = Cache::remember('electricity', 3600, fn () => $this->client->getElectricityPrices()->toArray());
|
||||
$data = Cache::remember('electricity:upcomming', 3600, fn () => $this->client->getElectricityPrices()->toArray());
|
||||
|
||||
return collect(ElectricityData::collect($data));
|
||||
return ElectricityData::collect($data, Collection::class);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function retrieveGas(): Collection
|
||||
{
|
||||
$data = Cache::remember('gas', 3600, fn () => $this->client->getGasPrices()->toArray());
|
||||
$data = Cache::remember('gas:upcomming', 3600, fn () => $this->client->getGasPrices()->toArray());
|
||||
|
||||
return collect(GasData::collect($data));
|
||||
return GasData::collect($data, Collection::class);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function retrieveElectricityForDate(Carbon $date): Collection
|
||||
{
|
||||
$data = Cache::remember('electricity:'.$date->format('Y-m-d'), 3600, fn () => $this->client->getElectricityPricesForDate($date)->toArray());
|
||||
|
||||
return GasData::collect($data, Collection::class);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function retrieveGasForDate(Carbon $date): Collection
|
||||
{
|
||||
$data = Cache::remember('gas:'.$date->format('Y-m-d'), 3600, fn () => $this->client->getGasPricesForDate($date)->toArray());
|
||||
|
||||
return GasData::collect($data, Collection::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user