/**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     \Log::info('[' . $this->job->getJobId() . ':' . $this->attempts() . '] Fetch datasource columns started.');
     $datasource = DataSource::find($this->datasource_id);
     if (!$datasource) {
         return;
     }
     if ($this->attempts() > 3) {
         $datasource->config_status = 0;
         $datasource->save();
         \Log::info('[' . $this->job->getJobId() . ':' . $this->attempts() . '] Fetch datasource columns failed.');
         return;
     }
     // TODO: Rename fetch function
     $ds_data = $datasource->fetch();
     if (!$ds_data) {
         $datasource->config_status = 0;
         $datasource->save();
     } else {
         $datasource->columns = array_keys($ds_data[0]);
         $datasource->config_status = 2;
         $datasource->save();
     }
     \Log::info('[' . $this->job->getJobId() . ':' . $this->attempts() . '] Fetch datasource columns successful.');
 }
Exemple #2
0
 /**
  * CONFIG STATUS
  * -------------
  * 0: Failed to configure
  * 1: Configured successfully
  * 2: Ready to configure
  * 3: Fetching columns
  * 4:
  */
 public static function boot()
 {
     parent::boot();
     // Setup event bindings...
     DataSource::created(function ($datasource) {
         \Queue::push(new DataSourceQueue($datasource->id));
     });
     DataSource::deleting(function ($datasource) {
         DataSourceSync::where('datasource_id', $datasource->id)->delete();
         $projects = $datasource->projects;
         foreach ($projects as $project) {
             $project->delete();
         }
     });
 }
Exemple #3
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     \Log::info('[' . $this->job->getJobId() . ':' . $this->attempts() . '] Sync started.');
     ini_set('memory_limit', '256M');
     if ($this->attempts() > 3) {
         \Log::info('[' . $this->job->getJobId() . ':' . $this->attempts() . '] Sync failed.');
     } else {
         $sync = Sync::find($this->sync_id);
         $datasources = DataSource::where('config_status', 1)->get();
         foreach ($datasources as $datasource) {
             $datasource->syncData($sync);
         }
         // TODO: Check if all data sources synced successfully
         $sync->sync_status = 1;
         $sync->save();
         \Log::info('[' . $this->job->getJobId() . ':' . $this->attempts() . '] Sync completed.');
     }
     return;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     DataSource::find($id)->delete();
     return response()->json(array('error' => false, 'message' => 'Datasource deleted.'), 200);
 }
 public function showDataSources()
 {
     $datasources = DataSource::all();
     $data = array('datasources' => $datasources);
     return view('dashboard.datasources', $data);
 }