mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-15 11:12:08 -06:00
Fix #3443
This commit is contained in:
parent
1cba62aa42
commit
a35bccb940
@ -25,6 +25,7 @@ namespace FireflyIII\Support;
|
|||||||
use Cache;
|
use Cache;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Models\Configuration;
|
use FireflyIII\Models\Configuration;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +81,11 @@ class FireflyConfig
|
|||||||
return Cache::get($fullName);
|
return Cache::get($fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = Configuration::where('name', $name)->first(['id', 'name', 'data']);
|
try {
|
||||||
|
$config = Configuration::where('name', $name)->first(['id', 'name', 'data']);
|
||||||
|
} catch (QueryException|Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($config) {
|
if ($config) {
|
||||||
Cache::forever($fullName, $config);
|
Cache::forever($fullName, $config);
|
||||||
@ -148,7 +153,15 @@ class FireflyConfig
|
|||||||
}
|
}
|
||||||
Log::debug('Set new value for ', ['name' => $name]);
|
Log::debug('Set new value for ', ['name' => $name]);
|
||||||
/** @var Configuration $config */
|
/** @var Configuration $config */
|
||||||
$config = Configuration::whereName($name)->first();
|
try {
|
||||||
|
$config = Configuration::whereName($name)->first();
|
||||||
|
} catch (QueryException|Exception $e) {
|
||||||
|
$item = new Configuration;
|
||||||
|
$item->name = $name;
|
||||||
|
$item->data = $value;
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
if (null === $config) {
|
if (null === $config) {
|
||||||
Log::debug('Does not exist yet ', ['name' => $name]);
|
Log::debug('Does not exist yet ', ['name' => $name]);
|
||||||
/** @var Configuration $item */
|
/** @var Configuration $item */
|
||||||
|
@ -23,8 +23,10 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Support;
|
namespace FireflyIII\Support;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Models\Telemetry as TelemetryModel;
|
use FireflyIII\Models\Telemetry as TelemetryModel;
|
||||||
use FireflyIII\Support\System\GeneratesInstallationId;
|
use FireflyIII\Support\System\GeneratesInstallationId;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@ -126,12 +128,17 @@ class Telemetry
|
|||||||
Log::error(sprintf('JSON Exception encoding the following value: %s: %s', $value, $e->getMessage()));
|
Log::error(sprintf('JSON Exception encoding the following value: %s: %s', $value, $e->getMessage()));
|
||||||
$jsonEncoded = [];
|
$jsonEncoded = [];
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
$count = TelemetryModel
|
||||||
|
::where('type', $type)
|
||||||
|
->where('key', $key)
|
||||||
|
->where('value', $jsonEncoded)
|
||||||
|
->count();
|
||||||
|
} catch (QueryException|Exception $e) {
|
||||||
|
$count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return TelemetryModel
|
return $count > 0;
|
||||||
::where('type', $type)
|
|
||||||
->where('key', $key)
|
|
||||||
->where('value', $jsonEncoded)
|
|
||||||
->count() > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,14 +178,17 @@ class Telemetry
|
|||||||
$this->generateInstallationId();
|
$this->generateInstallationId();
|
||||||
$config = app('fireflyconfig')->get('installation_id', null);
|
$config = app('fireflyconfig')->get('installation_id', null);
|
||||||
$installationId = null !== $config ? $config->data : 'empty';
|
$installationId = null !== $config ? $config->data : 'empty';
|
||||||
TelemetryModel::create(
|
try {
|
||||||
[
|
TelemetryModel::create(
|
||||||
'installation_id' => $installationId,
|
[
|
||||||
'key' => $name,
|
'installation_id' => $installationId,
|
||||||
'type' => $type,
|
'key' => $name,
|
||||||
'value' => $value,
|
'type' => $type,
|
||||||
]
|
'value' => $value,
|
||||||
);
|
]
|
||||||
|
);
|
||||||
|
} catch (QueryException|Exception $e) {
|
||||||
|
// ignore.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user