familytree365 /
backend
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Jobs; |
||||
| 4 | |||||
| 5 | use App\Models\Dna; |
||||
| 6 | use App\Models\DnaMatching as DM; |
||||
| 7 | use Illuminate\Bus\Queueable; |
||||
| 8 | use Illuminate\Contracts\Queue\ShouldQueue; |
||||
| 9 | use Illuminate\Foundation\Bus\Dispatchable; |
||||
| 10 | use Illuminate\Queue\InteractsWithQueue; |
||||
| 11 | use Illuminate\Queue\SerializesModels; |
||||
| 12 | use Spatie\Multitenancy\Jobs\TenantAware; |
||||
| 13 | |||||
| 14 | class DnaMatching implements ShouldQueue, TenantAware |
||||
| 15 | { |
||||
| 16 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 17 | |||||
| 18 | protected $current_user; |
||||
| 19 | protected $var_name; |
||||
| 20 | protected $file_name; |
||||
| 21 | |||||
| 22 | /** |
||||
| 23 | * Create a new job instance. |
||||
| 24 | * |
||||
| 25 | * @return void |
||||
| 26 | */ |
||||
| 27 | public function __construct($current_user, $var_name, $file_name) |
||||
| 28 | { |
||||
| 29 | $this->current_user = $current_user; |
||||
| 30 | $this->var_name = $var_name; |
||||
| 31 | $this->file_name = $file_name; |
||||
| 32 | } |
||||
| 33 | |||||
| 34 | /** |
||||
| 35 | * Execute the job. |
||||
| 36 | * |
||||
| 37 | * @return void |
||||
| 38 | */ |
||||
| 39 | public function handle() |
||||
| 40 | { |
||||
| 41 | $user = $this->current_user; |
||||
| 42 | $dnas = Dna::where('variable_name', '!=', $this->var_name)->get(); |
||||
| 43 | foreach ($dnas as $dna) { |
||||
| 44 | // system('/usr/bin/python3 /home/genealogia/public_html/dna.py ' . $this->var_name . ' ' . $dna->variable_name . ' ' . '/home/genealogia/public_html/storage/app/dna/'. $this->file_name . ' ' . '/home/genealogia/public_html/storage/app/dna/'. $dna->file_name); |
||||
| 45 | chdir('/var/www/api.familytree365.com/app'); |
||||
| 46 | exec('python3 dna.py '.$this->var_name.' '.$dna->variable_name.' '.$this->file_name.' '.$dna->file_name); |
||||
| 47 | $dm = new DM(); |
||||
| 48 | $dm->user_id = $user->id; |
||||
| 49 | $dm->image = 'shared_dna_'.$this->var_name.'_'.$dna->variable_name.'.png'; |
||||
| 50 | $dm->file1 = 'discordant_snps_'.$this->var_name.'_'.$dna->variable_name.'_GRCh37.csv'; |
||||
| 51 | $dm->file2 = 'shared_dna_one_chrom_'.$this->var_name.'_'.$dna->variable_name.'_GRCh37.csv'; |
||||
| 52 | $dm->save(); |
||||
| 53 | |||||
| 54 | $data = readCSV(storage_path('app'.DIRECTORY_SEPARATOR.'dna'.DIRECTORY_SEPARATOR.'output'.DIRECTORY_SEPARATOR.$dm->file1), ','); |
||||
| 55 | array_shift($data); |
||||
| 56 | $data = writeCSV(storage_path('app'.DIRECTORY_SEPARATOR.'dna'.DIRECTORY_SEPARATOR.'output'.DIRECTORY_SEPARATOR.$dm->file1), $data); |
||||
|
0 ignored issues
–
show
Are you sure the assignment to
$data is correct as writeCSV(storage_path('a...R . $dm->file1), $data) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||||
| 57 | |||||
| 58 | $data = readCSV(storage_path('app'.DIRECTORY_SEPARATOR.'dna'.DIRECTORY_SEPARATOR.'output'.DIRECTORY_SEPARATOR.$dm->file2), ','); |
||||
| 59 | array_shift($data); |
||||
|
0 ignored issues
–
show
$data of type null is incompatible with the type array expected by parameter $array of array_shift().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 60 | |||||
| 61 | $temp_data = $data; |
||||
| 62 | array_shift($temp_data); |
||||
| 63 | array_shift($temp_data); |
||||
| 64 | $total_cms = 0; |
||||
| 65 | $largest_cm = 0; |
||||
| 66 | foreach ($temp_data as $line) { |
||||
| 67 | if ($line[4] >= $largest_cm) { |
||||
| 68 | $largest_cm = $line[4]; |
||||
| 69 | } |
||||
| 70 | $total_cms = $total_cms + $line[4]; |
||||
| 71 | } |
||||
| 72 | $dm->user_id = $user->id; |
||||
| 73 | $dm->total_shared_cm = $total_cms; |
||||
| 74 | $dm->largest_cm_segment = round($largest_cm, 2); |
||||
| 75 | $dm->save(); |
||||
| 76 | |||||
| 77 | $data = writeCSV(storage_path('app'.DIRECTORY_SEPARATOR.'dna'.DIRECTORY_SEPARATOR.'output'.DIRECTORY_SEPARATOR.$dm->file2), $data); |
||||
|
0 ignored issues
–
show
Are you sure the assignment to
$data is correct as writeCSV(storage_path('a...R . $dm->file2), $data) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||||
| 78 | } |
||||
| 79 | } |
||||
| 80 | } |
||||
| 81 |