From d73e05b5df938e225cb23e24ba9e158550c3d8f9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 24 Jan 2024 14:58:06 +1100 Subject: [PATCH] Fixes for check data --- app/Console/Commands/CheckData.php | 13 ++++++++++++- app/Libraries/MultiDB.php | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 94a1c6e105ec..709ccecc0d59 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -918,7 +918,18 @@ class CheckData extends Command $p->saveQuietly(); - $this->logMessage("Fixing currency for # {$p->id}"); + $this->logMessage("Fixing currency for # {$p->id}"); + + }); + + Company::whereNull("subdomain") + ->cursor() + ->when(Ninja::isHosted()) + ->each(function ($c) { + $c->subdomain = MultiDB::randomSubdomainGenerator(); + $c->save(); + + $this->logMessage("Fixing subdomain for # {$c->id}"); }); diff --git a/app/Libraries/MultiDB.php b/app/Libraries/MultiDB.php index f03442c35402..fd028a03811c 100644 --- a/app/Libraries/MultiDB.php +++ b/app/Libraries/MultiDB.php @@ -557,9 +557,9 @@ class MultiDB $current_db = config('database.default'); do { - $length = 8; + $length = 10; $string = ''; - $vowels = ['a', 'e', 'i', 'o', 'u']; + $vowels = ['a', 'e', 'i', 'o', 'u', 'y']; $consonants = [ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', @@ -568,7 +568,7 @@ class MultiDB $max = $length / 2; for ($i = 1; $i <= $max; $i++) { $string .= $consonants[rand(0, 19)]; - $string .= $vowels[rand(0, 4)]; + $string .= $vowels[rand(0, 5)]; } } while (! self::checkDomainAvailable($string));