<commit_before><?php

namespace App\Jobs;


use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Storage;
use App\DeviceData;
use App\Device;

use App\DownloadJob;

use GuzzleHttp\Client;

use ZipArchive;

// use Upyun\Upyun;
// use Upyun\Config;

class DownloadData implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    protected $options;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($options)
    {
        $this->options = $options;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $image_url_prefix = 'http://thc-platfrom-storage.b0.upaiyun.com';
        $root_path = 'storage/app/';
        $unique_key = md5(uniqid());
        $download_job = DownloadJob::find($this->options['id']);
        $folder_name = (string)($download_job->user_id).'-'.($download_job->created_at)->toDateTimeString().'-'.$unique_key;
        $folder_name = join('_', explode(' ', $folder_name));
        $folder_path = $folder_name.'/';
        Storage::makeDirectory($folder_path);
        $query_options = json_decode($this->options['options']);
        for ($i=0; $i < count($query_options->device_ids); $i++){
            $device_datas = DeviceData::where('device_id', $query_options->device_ids[$i])
                                        ->whereBetween('created_at', [$query_options->start_at, $query_options->end_at])
                                        ->get();
            $device_datas_image = array();
            $raw_device_datas_data = $device_datas->filter(function($item, $key) use (&$device_datas_image) {
                $data = $item->data;
                $config = $item->config->data;
                foreach ($data as $key => $value){
                    $type = $config[$key]['type'];
                    if ($type == 'image'){
                        $item->image_key = $key;
                        array_push($device_datas_image, $item);
                        return false;
                    }
                }
                return true;
            });
            if ($query_options->with_image){
                $image_folder_path = $folder_path.$query_options->device_ids[$i].'/';
                Storage::makeDirectory($image_folder_path);<commit_msg>fix download job path problem<commit_after><?php

namespace App\Jobs;


use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Storage;
use App\DeviceData;
use App\Device;

use App\DownloadJob;

use GuzzleHttp\Client;

use ZipArchive;

// use Upyun\Upyun;
// use Upyun\Config;

class DownloadData implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    protected $options;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($options)
    {
        $this->options = $options;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $image_url_prefix = 'http://thc-platfrom-storage.b0.upaiyun.com';
        $root_path = storage_path().'/app/';
        $unique_key = md5(uniqid());
        $download_job = DownloadJob::find($this->options['id']);
        $folder_name = (string)($download_job->user_id).'-'.($download_job->created_at)->toDateTimeString().'-'.$unique_key;
        $folder_name = join('_', explode(' ', $folder_name));
        $folder_path = $folder_name.'/';
        Storage::makeDirectory($folder_path);
        $query_options = json_decode($this->options['options']);
        for ($i=0; $i < count($query_options->device_ids); $i++){
            $device_datas = DeviceData::where('device_id', $query_options->device_ids[$i])
                                        ->whereBetween('created_at', [$query_options->start_at, $query_options->end_at])
                                        ->get();
            $device_datas_image = array();
            $raw_device_datas_data = $device_datas->filter(function($item, $key) use (&$device_datas_image) {
                $data = $item->data;
                $config = $item->config->data;
                foreach ($data as $key => $value){
                    $type = $config[$key]['type'];
                    if ($type == 'image'){
                        $item->image_key = $key;
                        array_push($device_datas_image, $item);
                        return false;
                    }
                }
                return true;
            });
            if ($query_options->with_image){
                $image_folder_path = $folder_path.$query_options->device_ids[$i].'/';
                Storage::makeDirectory($image_folder_path);
{'fraction_non_alphanumeric': 0.14254121431443506, 'fraction_numerical': 0.0012062726176115801, 'mean_word_length': 2.1407828282828283, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6934032', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1428, 'n_words': 247}