@@ -27,7 +27,7 @@ public function authorize()
2727 */
2828 public function rules ()
2929 {
30- $ user = $ this ->user ();
30+ $ user = request () ->user ();
3131 $ filters = $ this ->input ('filters ' , []);
3232
3333 $ rules = [
@@ -96,4 +96,58 @@ public function rules()
9696
9797 return $ rules ;
9898 }
99+
100+ public function bodyParameters ()
101+ {
102+ return [
103+ 'mode ' => [
104+ 'description ' => 'Which date frequency to group the data by, like `hour`, `day`, etc. ' ,
105+ 'example ' => TimeSeriesModes::MONTH ->value ,
106+ ],
107+
108+ 'metric ' => [
109+ 'description ' => 'Which metric to use for the stat. ' ,
110+ 'example ' => TimeSeriesStats::allowedMetrics ([], request ()->user ())[0 ] ?? '' ,
111+ ],
112+
113+ 'date_range ' => [
114+ 'description ' => 'Preset date range to filter results by. ' ,
115+ 'example ' => PresetDateRanges::THIS_YEAR ->value ,
116+ ],
117+
118+ 'date_from ' => [
119+ 'description ' => 'Custom starting date when not using a preset date range. ' ,
120+ ],
121+
122+ 'date_to ' => [
123+ 'description ' => 'Custom ending date when not using a preset date range. ' ,
124+ ],
125+
126+ 'compare ' => [
127+ 'description ' => 'Whether to compare the stat with the comparison date range. ' ,
128+ 'example ' => true ,
129+ ],
130+
131+ 'compare_date_range ' => [
132+ 'description ' => 'Preset date range to compare results with. If not set, the previous date range will be compared. ' ,
133+ 'example ' => 'No-example '
134+ ],
135+
136+ 'compare_date_from ' => [
137+ 'description ' => 'Custom starting compare date when not using a preset compare date range. ' ,
138+ ],
139+
140+ 'compare_date_to ' => [
141+ 'description ' => 'Custom ending compare date when not using a preset compare date range. ' ,
142+ ],
143+
144+ 'format ' => [
145+ 'description ' => 'Which format to return the results in. ' ,
146+ ],
147+
148+ 'filters ' => [
149+ 'description ' => 'Filters to apply to the stat. ' ,
150+ ],
151+ ];
152+ }
99153}
0 commit comments