mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
parent
85204de9aa
commit
c98706fac0
@ -132,11 +132,9 @@ class ExportData extends Command
|
||||
if (!empty($data)) {
|
||||
try {
|
||||
$this->exportData($options, $data);
|
||||
app('telemetry')->feature('system.command.executed', 'firefly-iii:export-data');
|
||||
} catch (FireflyException $e) {
|
||||
$this->error(sprintf('Could not store data: %s', $e->getMessage()));
|
||||
|
||||
app('telemetry')->feature('system.command.errored', 'firefly-iii:export-data');
|
||||
$returnCode = 1;
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,6 @@ class ScanAttachments extends Command
|
||||
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
|
||||
}
|
||||
|
||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -60,8 +60,6 @@ class SetLatestVersion extends Command
|
||||
app('fireflyconfig')->set('ff3_version', config('firefly.version'));
|
||||
$this->line('Updated version.');
|
||||
|
||||
app('telemetry')->feature('system.command.executed', 'firefly-iii:set-latest-version');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -99,8 +99,6 @@ class ApplyRules extends Command
|
||||
|
||||
$result = $this->verifyInput();
|
||||
if (false === $result) {
|
||||
app('telemetry')->feature('system.command.errored', 'firefly-iii:apply-rules');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -119,8 +117,6 @@ class ApplyRules extends Command
|
||||
$this->warn(' --rule_groups=1,2,...');
|
||||
$this->warn(' --all_rules');
|
||||
|
||||
app('telemetry')->feature('system.command.errored', 'firefly-iii:apply-rules');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -148,8 +144,6 @@ class ApplyRules extends Command
|
||||
// file the rule(s)
|
||||
$ruleEngine->fire();
|
||||
|
||||
app('telemetry')->feature('system.command.executed', 'firefly-iii:apply-rules');
|
||||
|
||||
$this->line('');
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->line(sprintf('Done in %s seconds!', $end));
|
||||
|
@ -92,8 +92,6 @@ class Cron extends Command
|
||||
|
||||
$this->info('More feedback on the cron jobs can be found in the log files.');
|
||||
|
||||
app('telemetry')->feature('system.command.executed', 'firefly-iii:cron');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -63,18 +63,6 @@ class UpgradeFireflyInstructions extends Command
|
||||
$this->installInstructions();
|
||||
}
|
||||
|
||||
// collect system telemetry
|
||||
$isDocker = true === env('IS_DOCKER', false) ? 'true' : 'false';
|
||||
app('telemetry')->feature('system.php.version', PHP_VERSION);
|
||||
app('telemetry')->feature('system.os.version', PHP_OS);
|
||||
app('telemetry')->feature('system.database.driver', env('DB_CONNECTION', '(unknown)'));
|
||||
app('telemetry')->feature('system.os.is_docker', $isDocker);
|
||||
try {
|
||||
app('telemetry')->feature('system.users.count', (string)User::count());
|
||||
} catch (QueryException $e) {
|
||||
// @ignoreException
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class AccountFactory
|
||||
// try with type:
|
||||
if (null === $result) {
|
||||
$types = config(sprintf('firefly.accountTypeByIdentifier.%s', $accountTypeName)) ?? [];
|
||||
if (count($types) > 0) {
|
||||
if (!empty($types)) {
|
||||
$result = AccountType::whereIn('type', $types)->first();
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
return [
|
||||
'journals' => $journals,
|
||||
'currency' => $currency,
|
||||
'exists' => 0!==count($journals),
|
||||
'exists' => !empty($journals),
|
||||
'end' => $this->end->formatLocalized((string)trans('config.month_and_day', [], $locale)),
|
||||
'endBalance' => app('steam')->balance($account, $this->end),
|
||||
'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day', [], $locale)),
|
||||
|
@ -179,7 +179,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
*/
|
||||
protected function getExpenses(): array
|
||||
{
|
||||
if (count($this->expenses) > 0) {
|
||||
if (!empty($this->expenses)) {
|
||||
Log::debug('Return previous set of expenses.');
|
||||
|
||||
return $this->expenses;
|
||||
|
@ -188,7 +188,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
*/
|
||||
protected function getExpenses(): array
|
||||
{
|
||||
if (count($this->expenses) > 0) {
|
||||
if (!empty($this->expenses)) {
|
||||
Log::debug('Return previous set of expenses.');
|
||||
|
||||
return $this->expenses;
|
||||
@ -213,7 +213,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
*/
|
||||
protected function getIncome(): array
|
||||
{
|
||||
if (count($this->income) > 0) {
|
||||
if (!empty($this->income)) {
|
||||
return $this->income;
|
||||
}
|
||||
|
||||
|
@ -100,10 +100,6 @@ class UpdateController extends Controller
|
||||
$channel = $request->get('update_channel');
|
||||
$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';
|
||||
|
||||
// store as telemetry
|
||||
app('telemetry')->feature('admin.update.channel', $channel);
|
||||
app('telemetry')->feature('admin.update.permission', (string)$checkForUpdates);
|
||||
|
||||
app('fireflyconfig')->set('permission_update_check', $checkForUpdates);
|
||||
app('fireflyconfig')->set('last_update_check', time());
|
||||
app('fireflyconfig')->set('update_channel', $channel);
|
||||
|
@ -112,9 +112,6 @@ class RegisterController extends Controller
|
||||
|
||||
$this->registered($request, $user);
|
||||
|
||||
// telemetry
|
||||
app('telemetry')->feature('system.users.count', (string)User::count());
|
||||
|
||||
return redirect($this->redirectPath());
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ class ExpenseReportController extends Controller
|
||||
$newSet[$key] = $entry;
|
||||
}
|
||||
}
|
||||
if (0===count($newSet)) {
|
||||
if (empty($newSet)) {
|
||||
$newSet = $chartData;
|
||||
}
|
||||
$data = $this->generator->multiSet($newSet);
|
||||
|
@ -189,7 +189,7 @@ class BoxController extends Controller
|
||||
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
|
||||
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
||||
}
|
||||
if (0===count($sums)) {
|
||||
if (empty($sums)) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
||||
$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
||||
|
@ -64,7 +64,7 @@ class FrontpageController extends Controller
|
||||
}
|
||||
}
|
||||
$html = '';
|
||||
if (0!==count($info)) {
|
||||
if (!empty($info)) {
|
||||
try {
|
||||
$html = prefixView('json.piggy-banks', compact('info'))->render();
|
||||
|
||||
|
@ -125,11 +125,6 @@ class NewUserController extends Controller
|
||||
'invoice_date' => false, 'internal_reference' => false, 'notes' => true, 'attachments' => true,];
|
||||
app('preferences')->set('transaction_journal_optional_fields', $visibleFields);
|
||||
|
||||
// telemetry: user language preference + default language.
|
||||
app('telemetry')->feature('config.firefly.default_language', config('firefly.default_language', 'en_US'));
|
||||
app('telemetry')->feature('user.preferences.language', app('steam')->getLanguage());
|
||||
app('telemetry')->feature('user.preferences.locale', app('steam')->getLocale());
|
||||
|
||||
session()->flash('success', (string) trans('firefly.stored_new_accounts_new_user'));
|
||||
app('preferences')->mark();
|
||||
|
||||
|
@ -217,11 +217,6 @@ class PreferencesController extends Controller
|
||||
session()->flash('success', (string)trans('firefly.saved_preferences'));
|
||||
app('preferences')->mark();
|
||||
|
||||
// telemetry: user language preference + default language.
|
||||
app('telemetry')->feature('config.firefly.default_language', config('firefly.default_language', 'en_US'));
|
||||
app('telemetry')->feature('user.preferences.language', app('steam')->getLanguage());
|
||||
app('telemetry')->feature('user.preferences.locale', app('steam')->getLocale());
|
||||
|
||||
return redirect(route('preferences.index'));
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
|
||||
// add sort parameters. At this point they're filtered to allowed fields to sort by:
|
||||
if (count($sort) > 0) {
|
||||
if (!empty($sort)) {
|
||||
foreach ($sort as $param) {
|
||||
$query->orderBy($param[0], $param[1]);
|
||||
}
|
||||
|
@ -542,8 +542,6 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
'order' => $order,
|
||||
'active' => $active,
|
||||
];
|
||||
app('telemetry')->feature('rules.triggers.uses_trigger', $trigger['type']);
|
||||
|
||||
$this->storeTrigger($rule, $triggerValues);
|
||||
++$order;
|
||||
}
|
||||
@ -571,8 +569,6 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
'order' => $order,
|
||||
'active' => $active,
|
||||
];
|
||||
app('telemetry')->feature('rules.actions.uses_action', $action['type']);
|
||||
|
||||
$this->storeAction($rule, $actionValues);
|
||||
++$order;
|
||||
}
|
||||
|
@ -380,7 +380,6 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
{
|
||||
/** @var GroupUpdateService $service */
|
||||
$service = app(GroupUpdateService::class);
|
||||
|
||||
return $service->update($transactionGroup, $data);
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ trait RecurringTransactionTrait
|
||||
*/
|
||||
protected function updateTags(RecurrenceTransaction $transaction, array $tags): void
|
||||
{
|
||||
if (count($tags) > 0) {
|
||||
if (!empty($tags)) {
|
||||
/** @var RecurrenceMeta|null $entry */
|
||||
$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();
|
||||
if (null === $entry) {
|
||||
|
@ -32,7 +32,7 @@ use Log;
|
||||
|
||||
/**
|
||||
* Class GroupUpdateService
|
||||
* See reference nr. 91
|
||||
* See reference nr. 91
|
||||
*/
|
||||
class GroupUpdateService
|
||||
{
|
||||
@ -57,6 +57,7 @@ class GroupUpdateService
|
||||
$transactionGroup->save();
|
||||
}
|
||||
|
||||
|
||||
if (empty($transactions)) {
|
||||
Log::debug('No transactions submitted, do nothing.');
|
||||
|
||||
@ -105,6 +106,9 @@ class GroupUpdateService
|
||||
*/
|
||||
private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void
|
||||
{
|
||||
if (empty($data)) {
|
||||
return;
|
||||
}
|
||||
/** @var JournalUpdateService $updateService */
|
||||
$updateService = app(JournalUpdateService::class);
|
||||
$updateService->setTransactionGroup($transactionGroup);
|
||||
|
@ -48,7 +48,7 @@ use Log;
|
||||
* Class to centralise code that updates a journal given the input by system.
|
||||
*
|
||||
* Class JournalUpdateService
|
||||
* See reference nr. 93
|
||||
* See reference nr. 93
|
||||
*/
|
||||
class JournalUpdateService
|
||||
{
|
||||
@ -128,6 +128,11 @@ class JournalUpdateService
|
||||
public function update(): void
|
||||
{
|
||||
Log::debug(sprintf('Now in JournalUpdateService for journal #%d.', $this->transactionJournal->id));
|
||||
|
||||
if ($this->removeReconciliation()) {
|
||||
$this->data['reconciled'] = false;
|
||||
}
|
||||
|
||||
// can we update account data using the new type?
|
||||
if ($this->hasValidAccounts()) {
|
||||
Log::info('Account info is valid, now update.');
|
||||
@ -158,7 +163,7 @@ class JournalUpdateService
|
||||
$this->updateAmount();
|
||||
$this->updateForeignAmount();
|
||||
|
||||
// See reference nr. 94
|
||||
// See reference nr. 94
|
||||
|
||||
app('preferences')->mark();
|
||||
|
||||
@ -201,7 +206,7 @@ class JournalUpdateService
|
||||
$result = $validator->validateSource($sourceId, $sourceName, null);
|
||||
Log::debug(sprintf('hasValidSourceAccount(%d, "%s") will return %s', $sourceId, $sourceName, var_export($result, true)));
|
||||
|
||||
// See reference nr. 95
|
||||
// See reference nr. 95
|
||||
|
||||
// validate submitted info:
|
||||
return $result;
|
||||
@ -295,7 +300,7 @@ class JournalUpdateService
|
||||
$result = $validator->validateDestination($destId, $destName, null);
|
||||
Log::debug(sprintf('hasValidDestinationAccount(%d, "%s") will return %s', $destId, $destName, var_export($result, true)));
|
||||
|
||||
// See reference nr. 96
|
||||
// See reference nr. 96
|
||||
|
||||
// validate submitted info:
|
||||
return $result;
|
||||
@ -758,4 +763,19 @@ class JournalUpdateService
|
||||
$this->sourceTransaction->refresh();
|
||||
$this->destinationTransaction->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function removeReconciliation(): bool
|
||||
{
|
||||
if (count($this->data) > 1) {
|
||||
return true;
|
||||
}
|
||||
if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -297,8 +297,6 @@ class OperatorQuerySearch implements SearchInterface
|
||||
// check if alias, replace if necessary:
|
||||
$operator = self::getRootOperator($operator);
|
||||
|
||||
//app('telemetry')->feature('search.operators.uses_operator', $operator);
|
||||
|
||||
switch ($operator) {
|
||||
default:
|
||||
Log::error(sprintf('No such operator: %s', $operator));
|
||||
|
Loading…
Reference in New Issue
Block a user