Check data script for tasks
This commit is contained in:
parent
7c9a86267c
commit
7e286283c1
|
|
@ -87,7 +87,7 @@ class CheckData extends Command
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ninja:check-data {--database=} {--fix=} {--portal_url=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=} {--balance_status=} {--bank_transaction=} {--line_items=} {--payment_balance=}';
|
protected $signature = 'ninja:check-data {--database=} {--fix=} {--portal_url=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=} {--balance_status=} {--bank_transaction=} {--line_items=} {--payment_balance=} {--tasks=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -118,6 +118,7 @@ class CheckData extends Command
|
||||||
config(['database.default' => $database]);
|
config(['database.default' => $database]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->checkTaskTimeLogs();
|
||||||
$this->checkInvoiceBalances();
|
$this->checkInvoiceBalances();
|
||||||
$this->checkClientBalanceEdgeCases();
|
$this->checkClientBalanceEdgeCases();
|
||||||
$this->checkPaidToDatesNew();
|
$this->checkPaidToDatesNew();
|
||||||
|
|
@ -180,6 +181,30 @@ class CheckData extends Command
|
||||||
$this->log .= $str."\n";
|
$this->log .= $str."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkTaskTimeLogs()
|
||||||
|
{
|
||||||
|
\App\Models\Task::query()->cursor()->each(function ($task) {
|
||||||
|
$time_log = json_decode($task->time_log, true);
|
||||||
|
|
||||||
|
foreach($time_log as &$log){
|
||||||
|
if(count($log) > 4){
|
||||||
|
|
||||||
|
$this->logMessage("Task #{$task->id} has a time log with more than 4 elements");
|
||||||
|
|
||||||
|
if($this->option('tasks') == 'true'){
|
||||||
|
$log = [(int)$log[0], (int)$log[1], (string)$log[2], (bool)$log[3]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->option('tasks') == 'true'){
|
||||||
|
$task->time_log = json_encode($time_log);
|
||||||
|
$task->saveQuietly();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private function checkCompanyTokens()
|
private function checkCompanyTokens()
|
||||||
{
|
{
|
||||||
CompanyUser::query()->cursor()->each(function ($cu) {
|
CompanyUser::query()->cursor()->each(function ($cu) {
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ class StoreTaskRequest extends Request
|
||||||
return $fail('The '.$attribute.' - '.print_r($k, true).' is invalid. Unix timestamps only.');
|
return $fail('The '.$attribute.' - '.print_r($k, true).' is invalid. Unix timestamps only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array(count($k), [0,2,4])) {
|
if(count($k) > 4)) {
|
||||||
return $fail('The timelog must have 2 or 4 elements only.');
|
return $fail('The timelog can only have up to 4 elements.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($k[3]) && !is_bool($k[3])) {
|
if (isset($k[3]) && !is_bool($k[3])) {
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,8 @@ class UpdateTaskRequest extends Request
|
||||||
return $fail('The '.$attribute.' - '.print_r($k, true).' is invalid. Unix timestamps only.');
|
return $fail('The '.$attribute.' - '.print_r($k, true).' is invalid. Unix timestamps only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array(count($k), [0,2,4])) {
|
if(count($k) > 4)) {
|
||||||
return $fail('The timelog must have 2 or 4 elements only.');
|
return $fail('The timelog can only have up to 4 elements.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($k[3]) && !is_bool($k[3])) {
|
if(isset($k[3]) && !is_bool($k[3])) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue