0
私はアプリケーションがあり、時間枠に基づいていくつかのレポートを表示する必要があります。時間特有のレポートを生成するためのLaravel
したがって、イベントは起こったイベントに基づいてレポートされます - 成功率とMongoDBを使用しています。
これらは私のレポートパラメータになります。
Status | Total | Success | Failed | Success %
<5 Min 50 40 10
>5 min <15 min -- -- --
>15 min <hour -- -- --
だから私の質問は、以下の5分を取るすべてのレコードを、見つける合計を数え、失敗回数、および成功をカウントする方法です。
私のクエリは以下のとおりです。日付範囲に基づいて、まずレコードをソートする必要があります。その後、ステータスが成功したcreated_atとupdated_atの違いを見つける方法がわかりません。 5分未満、5分〜15分などである。
//convert the date to ISO to search in mongo
$from = Carbon::createFromFormat('Y-m-d', '2017-02-20');
$to = Carbon::createFromFormat('Y-m-d', '2017-02-21');
//select the sutiable app
$query = MyCollection::where('app_id', '12345');
//refine the results to the only selected date range.
//tried whereBetween here, but not seems to be working,
//hence used chained where
$filter_dates = $query->where('created_at', '>=', $from)
->where('created_at', '<=', $to);
//Here I have to select the records like where created_at
//and updated_at difference is like <5 mins, then next to
//>5 min and <15 mins and so on. I am struck here.
$filter_by_time = $filter_dates->
また、何をしているかを達成するためのより良いアプローチがあるかどうか教えてください。
あなたのテーブル構造を含みます – Beginner