Update installation commands.

This commit is contained in:
James Cole
2021-03-12 06:30:40 +01:00
parent 748d61fb8f
commit a05d006fa7
40 changed files with 1624 additions and 1470 deletions

View File

@@ -79,7 +79,7 @@ class AppendBudgetLimitPeriods extends Command
$this->theresNoLimit();
$this->markAsExecuted();
$this->markAsExecuted();
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Fixed budget limits in %s seconds.', $end));
@@ -100,6 +100,44 @@ class AppendBudgetLimitPeriods extends Command
return false; // @codeCoverageIgnore
}
/**
*
*/
private function theresNoLimit(): void
{
$limits = BudgetLimit::whereNull('period')->get();
/** @var BudgetLimit $limit */
foreach ($limits as $limit) {
$this->fixLimit($limit);
}
}
/**
* @param BudgetLimit $limit
*/
private function fixLimit(BudgetLimit $limit)
{
$period = $this->getLimitPeriod($limit);
if (null === $period) {
$message = sprintf(
'Could not guesstimate budget limit #%d (%s - %s) period.', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d')
);
$this->warn($message);
Log::warning($message);
return;
}
$limit->period = $period;
$limit->save();
$msg = sprintf(
'Budget limit #%d (%s - %s) period is "%s".', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d'), $period
);
Log::debug($msg);
}
/**
* @param BudgetLimit $limit
*
@@ -160,37 +198,4 @@ class AppendBudgetLimitPeriods extends Command
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
}
/**
*
*/
private function theresNoLimit(): void
{
$limits = BudgetLimit::whereNull('period')->get();
/** @var BudgetLimit $limit */
foreach ($limits as $limit) {
$this->fixLimit($limit);
}
}
/**
* @param BudgetLimit $limit
*/
private function fixLimit(BudgetLimit $limit)
{
$period = $this->getLimitPeriod($limit);
if (null === $period) {
$message = sprintf('Could not guesstimate budget limit #%d (%s - %s) period.', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d'));
$this->warn($message);
Log::warning($message);
return;
}
$limit->period = $period;
$limit->save();
$msg = sprintf('Budget limit #%d (%s - %s) period is "%s".', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d'), $period);
Log::debug($msg);
}
}