mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-10 13:21:21 +00:00
Optimize queries for statistics.
This commit is contained in:
@@ -66,4 +66,9 @@ class PeriodStatisticRepository implements PeriodStatisticRepositoryInterface
|
||||
|
||||
return $stat;
|
||||
}
|
||||
|
||||
public function allInRangeForModel(Model $model, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
return $model->primaryPeriodStatistics()->where('start','>=', $start)->where('end','<=', $end)->get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,6 @@ interface PeriodStatisticRepositoryInterface
|
||||
public function findPeriodStatistic(Model $model, Carbon $start, Carbon $end, string $type): Collection;
|
||||
|
||||
public function saveStatistic(Model $model, int $currencyId, Carbon $start, Carbon $end, string $type, int $count, string $amount): PeriodStatistic;
|
||||
|
||||
public function allInRangeForModel(Model $model, Carbon $start, Carbon $end): Collection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user