mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Optimize queries for statistics.
This commit is contained in:
@@ -63,7 +63,7 @@ trait CalculateXOccurrences
|
||||
$mutator = clone $date;
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$dayOfMonth = (int) $moment;
|
||||
$dayOfMonth = (int)$moment;
|
||||
if ($mutator->day > $dayOfMonth) {
|
||||
// day has passed already, add a month.
|
||||
$mutator->addMonth();
|
||||
@@ -89,10 +89,10 @@ trait CalculateXOccurrences
|
||||
*/
|
||||
protected function getXNDomOccurrences(Carbon $date, int $count, int $skipMod, string $moment): array
|
||||
{
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$mutator->addDay(); // always assume today has passed.
|
||||
$mutator->startOfMonth();
|
||||
// this feels a bit like a cop out but why reinvent the wheel?
|
||||
@@ -120,14 +120,14 @@ trait CalculateXOccurrences
|
||||
*/
|
||||
protected function getXWeeklyOccurrences(Carbon $date, int $count, int $skipMod, string $moment): array
|
||||
{
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
// monday = 1
|
||||
// sunday = 7
|
||||
$mutator->addDay(); // always assume today has passed.
|
||||
$dayOfWeek = (int) $moment;
|
||||
$dayOfWeek = (int)$moment;
|
||||
if ($mutator->dayOfWeekIso > $dayOfWeek) {
|
||||
// day has already passed this week, add one week:
|
||||
$mutator->addWeek();
|
||||
@@ -164,7 +164,7 @@ trait CalculateXOccurrences
|
||||
if ($mutator > $date) {
|
||||
$date->addYear();
|
||||
}
|
||||
$obj = clone $date;
|
||||
$obj = clone $date;
|
||||
while ($total < $count) {
|
||||
if (0 === $attempts % $skipMod) {
|
||||
$return[] = clone $obj;
|
||||
|
Reference in New Issue
Block a user