Ottimizzazione procedura di configurazione iniziale

This commit is contained in:
Dasc3er 2021-08-02 15:01:43 +02:00
parent bb5151329e
commit a8d500e674
3 changed files with 39 additions and 2 deletions

View File

@ -70,6 +70,11 @@ class UpdateController extends Controller
{ {
$migrator = self::getMigrator(); $migrator = self::getMigrator();
// Fallback per creazione tabella di migrazioni
if (!$migrator->getRepository()->repositoryExists()) {
$migrator->getRepository()->createRepository();
}
$paths = array_merge( $paths = array_merge(
$migrator->paths(), $migrator->paths(),
[app()->databasePath().DIRECTORY_SEPARATOR.'migrations'] [app()->databasePath().DIRECTORY_SEPARATOR.'migrations']
@ -144,7 +149,7 @@ class UpdateController extends Controller
$result = Update::doUpdate(self::$legacyUpdateRate); $result = Update::doUpdate(self::$legacyUpdateRate);
$rate = 0; $rate = 0;
if (is_array($result)) { if (!is_bool($result) && is_array($result)) {
$rate = $result[1] - $result[0]; $rate = $result[1] - $result[0];
} elseif (!empty($update['script'])) { } elseif (!empty($update['script'])) {
$rate = self::$legacyScriptValue; $rate = self::$legacyScriptValue;

View File

@ -8,6 +8,7 @@ use App\Http\Controllers\RequirementsController;
use App\Http\Controllers\UpdateController; use App\Http\Controllers\UpdateController;
use Closure; use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class EnsureConfiguration class EnsureConfiguration
{ {
@ -70,10 +71,18 @@ class EnsureConfiguration
*/ */
protected function checkRequirements($route) protected function checkRequirements($route)
{ {
// Controllo nella cache per evitare controlli in sequenza
$completed = Cache::get('requisiti_soddisfatti');
if ($completed) {
return true;
}
$configuration_paths = ['requirements']; $configuration_paths = ['requirements'];
$requirements_satisfied = RequirementsController::isSatisfied(); $requirements_satisfied = RequirementsController::isSatisfied();
if ($requirements_satisfied) { if ($requirements_satisfied) {
Cache::put('requisiti_soddisfatti', true);
// Redirect nel caso in cui i requisiti siano soddisfatti // Redirect nel caso in cui i requisiti siano soddisfatti
if (in_array($route->getName(), $configuration_paths)) { if (in_array($route->getName(), $configuration_paths)) {
$this->setRedirect(route('configuration')); $this->setRedirect(route('configuration'));
@ -97,10 +106,18 @@ class EnsureConfiguration
*/ */
protected function checkConfiguration($route) protected function checkConfiguration($route)
{ {
// Controllo nella cache per evitare controlli in sequenza
$completed = Cache::get('configurazione_completata');
if ($completed) {
return true;
}
$configuration_paths = ['configuration', 'configuration-save', 'configuration-write', 'configuration-test']; $configuration_paths = ['configuration', 'configuration-save', 'configuration-write', 'configuration-test'];
$configuration_completed = ConfigurationController::isConfigured(); $configuration_completed = ConfigurationController::isConfigured();
if ($configuration_completed) { if ($configuration_completed) {
Cache::put('configurazione_completata', true);
// Redirect nel caso in cui la configurazione sia correttamente funzionante // Redirect nel caso in cui la configurazione sia correttamente funzionante
if (in_array($route->getName(), $configuration_paths)) { if (in_array($route->getName(), $configuration_paths)) {
$this->setRedirect(route('update')); $this->setRedirect(route('update'));
@ -124,10 +141,18 @@ class EnsureConfiguration
*/ */
protected function checkMigrations($route) protected function checkMigrations($route)
{ {
// Controllo nella cache per evitare controlli in sequenza
$completed = Cache::get('aggiornamenti_eseguiti');
if ($completed) {
return true;
}
$update_paths = ['update', 'update-execute']; $update_paths = ['update', 'update-execute'];
$update_completed = UpdateController::isCompleted(); $update_completed = UpdateController::isCompleted();
if ($update_completed) { if ($update_completed) {
Cache::put('aggiornamenti_eseguiti', true);
// Redirect nel caso in cui la configurazione sia correttamente funzionante // Redirect nel caso in cui la configurazione sia correttamente funzionante
if (in_array($route->getName(), $update_paths)) { if (in_array($route->getName(), $update_paths)) {
$this->setRedirect(route('initialization')); $this->setRedirect(route('initialization'));
@ -151,10 +176,18 @@ class EnsureConfiguration
*/ */
protected function checkInitialization($route) protected function checkInitialization($route)
{ {
// Controllo nella cache per evitare controlli in sequenza
$completed = Cache::get('inizializzazione_completata');
if ($completed) {
return true;
}
$initialization_paths = ['initialization', 'initialization-save']; $initialization_paths = ['initialization', 'initialization-save'];
$initialization_completed = InitializationController::isInitialized(); $initialization_completed = InitializationController::isInitialized();
if ($initialization_completed) { if ($initialization_completed) {
Cache::put('inizializzazione_completata', true);
// Redirect nel caso in cui la configurazione sia correttamente funzionante // Redirect nel caso in cui la configurazione sia correttamente funzionante
if (in_array($route->getName(), $initialization_paths)) { if (in_array($route->getName(), $initialization_paths)) {
$this->setRedirect(route('login')); $this->setRedirect(route('login'));

View File

@ -46,7 +46,6 @@
"league/csv": "^8.2", "league/csv": "^8.2",
"mpdf/mpdf": "^8.0.10", "mpdf/mpdf": "^8.0.10",
"mpociot/vat-calculator": "^2.3", "mpociot/vat-calculator": "^2.3",
"nwidart/laravel-modules": "^8.2",
"owasp/csrf-protector-php": "^1.0", "owasp/csrf-protector-php": "^1.0",
"phpmailer/phpmailer": "^6.0", "phpmailer/phpmailer": "^6.0",
"respect/validation": "^1.1", "respect/validation": "^1.1",