Beispiel #1
0
 public function queueReport($data)
 {
     $data = $this->formatDates($data);
     $bq = new BigQueryApi();
     //start the the jobs
     $data = $bq->processTemplate($data);
     $data['bq_status'] = "processng";
     $this->create();
     $this->save($data);
 }
Beispiel #2
0
 public function refresh_report_status($report_id = false)
 {
     //get the report
     $_SERVER['FORCEMASTER'] = true;
     $report = $this->findById($report_id);
     $bq = new BigQueryApi();
     //get the job data
     $job_data = unserialize($report['Report']['job_data']);
     $report_data = !empty($report['Report']['report_data']) ? unserialize($report['Report']['report_data']) : array();
     foreach ($job_data as $k => $v) {
         $status = $bq->getJobStatus($v['jobReference']['jobId']);
         if ($status['status']['state'] == "DONE") {
             $report_data[$k] = $bq->jobs()->getQueryResults($bq->berrics_reports, $v['jobReference']['jobId']);
             unset($job_data[$k]);
         }
     }
     if (count($job_data) <= 0) {
         $this->update_report_status($report['Report']['id'], "completed");
         unset($report['Report']['report_status']);
     }
     $report['Report']['job_data'] = serialize($job_data);
     $report['Report']['report_data'] = serialize($report_data);
     $this->create();
     $this->id = $report['Report']['id'];
     unset($report['Report']['id']);
     $this->save($report['Report']);
     $report = $this->read();
     unset($_SERVER['FORCEMASTER']);
     return $report;
 }