Fix usage_broadband, since our usage data is a float
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 31s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
2024-07-26 14:45:43 +10:00
parent 667109150d
commit 1c4cb6f38c
5 changed files with 73 additions and 24 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use App\Jobs\BroadbandTraffic as Job;
use App\Models\Supplier;
@@ -15,7 +16,7 @@ class BroadbandTraffic extends Command
* @var string
*/
protected $signature = 'broadband:traffic:import'.
' {--s|supplier= : Supplier Name}';
' {supplier? : Supplier Name}';
/**
* The console command description.
@@ -31,14 +32,26 @@ class BroadbandTraffic extends Command
*/
public function handle()
{
if ($this->option('supplier')) {
$o = Supplier::where('name','ilike',$this->option('supplier'))->singleOrFail();
if ($this->argument('supplier')) {
try {
$o = Supplier::active()
->where('name','ilike',$this->argument('supplier'))
->sole();
Job::dispatchSync($o->id);
return;
} catch (ModelNotFoundException $e) {
$this->error(sprintf('Supplier [%s] not found',$this->argument('supplier')));
return self::FAILURE;
}
Job::dispatchSync($o->name);
return self::SUCCESS;
}
foreach (Supplier::active()->get() as $o)
Job::dispatchSync($o->id);
Job::dispatchSync($o->name);
return self::SUCCESS;
}
}