@@ -332,6 +332,8 @@ pub struct CountsRequest {
332332 pub start_time : String ,
333333 /// Excluded end time for counts query
334334 pub end_time : String ,
335+ /// optional number of bins to divide the time range into
336+ pub num_bins : Option < u64 > ,
335337 /// Conditions
336338 pub conditions : Option < CountConditions > ,
337339}
@@ -400,19 +402,23 @@ impl CountsRequest {
400402 . signed_duration_since ( time_range. start )
401403 . num_minutes ( ) as u64 ;
402404
403- // create number of bins based on total minutes
404- let num_bins = if total_minutes <= 60 * 5 {
405- // till 5 hours, 1 bin = 1 min
406- total_minutes
407- } else if total_minutes <= 60 * 24 {
408- // till 1 day, 1 bin = 5 min
409- total_minutes. div_ceil ( 5 )
410- } else if total_minutes <= 60 * 24 * 10 {
411- // till 10 days, 1 bin = 1 hour
412- total_minutes. div_ceil ( 60 )
405+ let num_bins = if let Some ( num_bins) = self . num_bins {
406+ num_bins
413407 } else {
414- // > 10 days, 1 bin = 1 day
415- total_minutes. div_ceil ( 1440 )
408+ // create number of bins based on total minutes
409+ if total_minutes <= 60 * 5 {
410+ // till 5 hours, 1 bin = 1 min
411+ total_minutes
412+ } else if total_minutes <= 60 * 24 {
413+ // till 1 day, 1 bin = 5 min
414+ total_minutes. div_ceil ( 5 )
415+ } else if total_minutes <= 60 * 24 * 10 {
416+ // till 10 days, 1 bin = 1 hour
417+ total_minutes. div_ceil ( 60 )
418+ } else {
419+ // > 10 days, 1 bin = 1 day
420+ total_minutes. div_ceil ( 1440 )
421+ }
416422 } ;
417423
418424 // divide minutes by num bins to get minutes per bin
0 commit comments