Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| FlyMsgAITrackingTrait | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| getFlyMsgAIByUsers | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| getTrackingUserId | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Traits\AccountCenter\Reporting; |
| 4 | |
| 5 | use App\Http\Models\FlyMsgAI\FlyMsgAITracking; |
| 6 | use Carbon\Carbon; |
| 7 | use MongoDB\BSON\UTCDateTime; |
| 8 | |
| 9 | trait FlyMsgAITrackingTrait |
| 10 | { |
| 11 | public function getFlyMsgAIByUsers($userIds, $feature, $fromDate, $toDate) |
| 12 | { |
| 13 | $query = FlyMsgAITracking::whereIn("user_id", $userIds); |
| 14 | |
| 15 | if ($fromDate && $toDate) { |
| 16 | $query = $query->whereBetween("created_at", [ |
| 17 | new UTCDateTime($fromDate->getTimestamp() * 1000), |
| 18 | new UTCDateTime($toDate->getTimestamp() * 1000), |
| 19 | ]); |
| 20 | } |
| 21 | |
| 22 | return $query->where("feature", "=", $feature)->get(); |
| 23 | } |
| 24 | |
| 25 | |
| 26 | public function getTrackingUserId($userId) |
| 27 | { |
| 28 | $startDay = Carbon::now()->startOfDay(); |
| 29 | return FlyMsgAITracking::where("user_id", $userId) |
| 30 | ->where("created_at", ">=", new UTCDateTime($startDay->getTimestamp() * 1000)) |
| 31 | ->get(); |
| 32 | } |
| 33 | } |