| @@ -2,13 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentSupport\App\Modules\Reporting; |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | - * ReportingHelperTrait is act as helper of report | |
| 7 | - * This will help to get frequency, several date format, get advanced or backdated date and other | |
| 8 | - * @package FluentSupport\App\Modules\Reporting | |
| 9 | - * | |
| 10 | - * @version 1.0.0 | |
| 6 | + * Date range, bucketing and formatting helpers for reports. | |
| 11 | 7 | */ |
| 12 | 8 | |
| 13 | 9 | trait ReportingHelperTrait |
| 14 | 10 | { |
| @@ -43,10 +39,11 @@ | ||
| 43 | 39 | } |
| 44 | 40 | |
| 45 | 41 | |
| 46 | 42 | /** |
| 47 | - * getFrequency method will return the frequency | |
| 48 | - * this function get date from and date to as parameter and find the frequency and return | |
| 43 | + * Bucket size for the range: hourly for one day, daily up to 62 days, | |
| 44 | + * weekly up to 181, monthly beyond. | |
| 45 | + * | |
| 49 | 46 | * @param $from |
| 50 | 47 | * @param $to |
| 51 | 48 | * @return string |
| 52 | 49 | */ |
| @@ -52,9 +49,8 @@ | ||
| 52 | 49 | */ |
| 53 | 50 | protected function getFrequency($from, $to) |
| 54 | 51 | { |
| 55 | 52 | $numDays = $to->diff($from)->format("%a"); |
| 56 | - //If number of days in the range is greater than 2 month and less than or equal to 3 months | |
| 57 | 53 | if($numDays <= 0) { |
| 58 | 54 | return static::$hourly; |
| 59 | 55 | } |
| 60 | 56 | else if ($numDays > 62 && $numDays <= 181) { |
| @@ -59,9 +55,8 @@ | ||
| 59 | 55 | } |
| 60 | 56 | else if ($numDays > 62 && $numDays <= 181) { |
| 61 | 57 | return static::$weekly; |
| 62 | 58 | } else if ($numDays > 181) { |
| 63 | - //Greater than 3 months | |
| 64 | 59 | return static::$monthly; |
| 65 | 60 | } |
| 66 | 61 | |
| 67 | 62 | return static::$daily; |
| @@ -67,9 +62,8 @@ | ||
| 67 | 62 | return static::$daily; |
| 68 | 63 | } |
| 69 | 64 | |
| 70 | 65 | /** |
| 71 | - * prepareSelect method will prepare the field to select | |
| 72 | 66 | * @param $frequency |
| 73 | 67 | * @param string $dateField |
| 74 | 68 | * @return array |
| 75 | 69 | */ |
| @@ -111,15 +105,14 @@ | ||
| 111 | 105 | $to->format('Y-m-d')." 23:59:59" |
| 112 | 106 | ]; |
| 113 | 107 | } |
| 114 | 108 | return [ |
| 115 | - $from->format('Y-m-d'), | |
| 116 | - $to->format('Y-m-d') | |
| 109 | + $from->format('Y-m-d')." 00:00:00", | |
| 110 | + $to->format('Y-m-d')." 23:59:59" | |
| 117 | 111 | ]; |
| 118 | 112 | } |
| 119 | 113 | |
| 120 | 114 | /** |
| 121 | - * getGroupAndOrder method will return order by and group by value based on frequency | |
| 122 | 115 | * @param $frequency |
| 123 | 116 | * @return string[] |
| 124 | 117 | */ |
| 125 | 118 | protected function getGroupAndOrder($frequency) |