Пример #1
0
 public function handle()
 {
     $date = new \DateTime('now');
     $countDecisionsPerMinute = Decision::where(['created_at' => ['$lt' => new UTCDatetime($date->getTimestamp() * 1000), '$gte' => new UTCDatetime($date->modify('-1 minute')->getTimestamp() * 1000)]])->count();
     $data = json_encode(['value' => $countDecisionsPerMinute, 'updated_at' => $date->format('Y-m-d H:i:s'), 'id' => $date->getTimestamp()]);
     $ch = curl_init();
     $headers = ['Content-Type: application/json', 'X-Cachet-Token: ' . config('services.status.access_token'), 'Content-Length: ' . strlen($data)];
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_URL, config('services.status.decisions_per_minute_link'));
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_exec($ch);
     curl_close($ch);
 }
Пример #2
0
 public function getDecisions($size = null, $table_id = null, $variant_id = null)
 {
     /** @var \Jenssegers\Mongodb\Eloquent\Builder $query */
     if ($table_id) {
         $query = $this->getModel()->query()->where('table._id', $table_id);
         if ($query->count() <= 0) {
             $e = new ModelNotFoundException();
             $e->setModel(Decision::class);
             throw $e;
         }
         $query = $query->orderBy(Decision::CREATED_AT, 'DESC');
     } elseif ($variant_id) {
         $query = $this->getModel()->query()->where('table.variant._id', $variant_id);
     } else {
         $query = Decision::orderBy(Decision::CREATED_AT, 'DESC');
     }
     $query = $query->where('applications', ApplicationableHelper::getApplicationId());
     return $this->paginateQuery($query, $size);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $row = \App\Models\Decision::find($id);
     $row->delete();
 }