diff --git a/app/Console/Commands/CheckDb.php b/app/Console/Commands/CheckDb.php index 63e4754f5b0d..a543f9f01914 100644 --- a/app/Console/Commands/CheckDb.php +++ b/app/Console/Commands/CheckDb.php @@ -67,20 +67,13 @@ use Symfony\Component\Console\Input\InputOption; */ class CheckDb extends Command { - /** - * @var string - */ + protected $signature = 'ninja:check-db'; - /** - * @var string - */ protected $description = 'Check MultiDB'; - protected $log = ''; - private $entities = [ Account::class, Activity::class, diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index fe5c16f34891..6f508b06e3ff 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -56,13 +56,9 @@ use stdClass; class CreateSingleAccount extends Command { use MakesHash, GeneratesCounter; - /** - * @var string - */ + protected $description = 'Create Single Sample Account'; - /** - * @var string - */ + protected $signature = 'ninja:create-single-account {gateway=all} {--database=db-ninja-01}'; protected $invoice_repo; @@ -71,18 +67,6 @@ class CreateSingleAccount extends Command protected $gateway; - /** - * Create a new command instance. - * - * @param InvoiceRepository $invoice_repo - */ - public function __construct(InvoiceRepository $invoice_repo) - { - parent::__construct(); - - $this->invoice_repo = $invoice_repo; - } - /** * Execute the console command. * @@ -94,6 +78,11 @@ class CreateSingleAccount extends Command if(config('ninja.is_docker')) return; + if (!$this->confirm('Are you sure you want to inject dummy data?')) + return; + + $this->invoice_repo = new InvoiceRepository(); + MultiDB::setDb($this->option('database')); $this->info(date('r').' Create Single Sample Account...'); diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index 6d1426c5ed7b..67dc7e5cd3cb 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -59,18 +59,6 @@ class CreateTestData extends Command protected $invoice_repo; - /** - * Create a new command instance. - * - * @param InvoiceRepository $invoice_repo - */ - public function __construct(InvoiceRepository $invoice_repo) - { - parent::__construct(); - - $this->invoice_repo = $invoice_repo; - } - /** * Execute the console command. * @@ -80,6 +68,11 @@ class CreateTestData extends Command { if(config('ninja.is_docker')) return; + + if (!$this->confirm('Are you sure you want to inject dummy data?')) + return; + + $this->invoice_repo = new InvoiceRepository(); $this->info(date('r').' Running CreateTestData...'); $this->count = $this->argument('count'); diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index 3119ac21b63e..5e5cfcbd7076 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -53,28 +53,15 @@ class DemoMode extends Command { use MakesHash, GeneratesCounter; - protected $name = 'ninja:demo-mode'; - /** - * The name and signature of the console command. - * - * @var string - */ protected $signature = 'ninja:demo-mode'; - /** - * The console command description. - * - * @var string - */ protected $description = 'Setup demo mode'; protected $invoice_repo; - public function __construct(InvoiceRepository $invoice_repo) + public function __construct() { parent::__construct(); - - $this->invoice_repo = $invoice_repo; } /** @@ -89,6 +76,8 @@ class DemoMode extends Command if(config('ninja.is_docker')) return; + $this->invoice_repo = new InvoiceRepository(); + $cached_tables = config('ninja.cached_tables'); foreach ($cached_tables as $name => $class) { diff --git a/app/Console/Commands/ParallelCheckData.php b/app/Console/Commands/ParallelCheckData.php index ca432b4f72ad..0c6d778f5cf0 100644 --- a/app/Console/Commands/ParallelCheckData.php +++ b/app/Console/Commands/ParallelCheckData.php @@ -39,7 +39,7 @@ class ParallelCheckData extends Command /** * @var string */ - protected $name = 'ninja:pcheck-data'; + protected $signature = 'ninja:pcheck-data'; /** * @var string diff --git a/app/Console/Commands/PostUpdate.php b/app/Console/Commands/PostUpdate.php index 1e5025dac200..491a60c7fdec 100644 --- a/app/Console/Commands/PostUpdate.php +++ b/app/Console/Commands/PostUpdate.php @@ -17,7 +17,6 @@ use Illuminate\Support\Facades\Artisan; class PostUpdate extends Command { - protected $name = 'ninja:post-update'; /** * The name and signature of the console command. * diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index caf7f5a58c61..e03d3b78f629 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -80,10 +80,14 @@ class Kernel extends ConsoleKernel /* Run hosted specific jobs */ if (Ninja::isHosted()) { - $schedule->job(new AdjustEmailQuota)->dailyAt('23:00')->withoutOverlapping(); + $schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping(); + $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping(); - $schedule->command('ninja:check-data --database=db-ninja-01')->daily()->withoutOverlapping(); - $schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:05')->withoutOverlapping(); + + $schedule->command('ninja:check-data --database=db-ninja-01')->daily('00:50')->withoutOverlapping(); + + $schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:55')->withoutOverlapping(); + $schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping(); } @@ -91,6 +95,7 @@ class Kernel extends ConsoleKernel if(config('queue.default') == 'database' && Ninja::isSelfHost() && config('ninja.internal_queue_enabled') && !config('ninja.is_docker')) { $schedule->command('queue:work')->everyMinute()->withoutOverlapping(); + $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping(); } diff --git a/app/Services/Invoice/ApplyNumber.php b/app/Services/Invoice/ApplyNumber.php index 71f0c81ea2ac..786051fb18c8 100644 --- a/app/Services/Invoice/ApplyNumber.php +++ b/app/Services/Invoice/ApplyNumber.php @@ -48,7 +48,6 @@ class ApplyNumber extends AbstractService break; default: - // code... break; } diff --git a/tests/Unit/RedisVsDatabaseTest.php b/tests/Unit/RedisVsDatabaseTest.php new file mode 100644 index 000000000000..f7b1b767466d --- /dev/null +++ b/tests/Unit/RedisVsDatabaseTest.php @@ -0,0 +1,76 @@ +markTestSkipped('Skip test no company gateways installed'); + + + } + + public function testRedisSpeed() + { + $start = microtime(true); + + $currencies = Cache::get('currencies'); + + $currency = $currencies->filter(function ($item) { + return $item->id == 17; + })->first(); + + + $total_time = microtime(true) - $start; + + $this->assertTrue(true); + // nlog($total_time); + //0.0012960433959961 + } + + + public function testDbSpeed() + { + $start = microtime(true); + + $currency = Currency::find(17); + + $total_time = microtime(true) - $start; + + + $this->assertTrue(true); + // nlog($total_time); + // 0.006152868270874 + + } + + + +} + + + + + \ No newline at end of file