@@ -241,7 +241,7 @@ pub async fn put_retention(
241
241
242
242
pub async fn get_stats (
243
243
stream_name : Path < String > ,
244
- params : Option < Query < StatsParams > > ,
244
+ Query ( params) : Query < StatsParams > ,
245
245
) -> Result < HttpResponse , StreamError > {
246
246
let stream_name = stream_name. into_inner ( ) ;
247
247
@@ -259,8 +259,7 @@ pub async fn get_stats(
259
259
}
260
260
}
261
261
262
- if let Some ( Query ( params) ) = params {
263
- let stats = params. get_stats ( & stream_name) ;
262
+ if let Some ( stats) = params. get_stats ( & stream_name) {
264
263
return Ok ( HttpResponse :: build ( StatusCode :: OK ) . json ( stats) ) ;
265
264
}
266
265
@@ -733,13 +732,13 @@ pub mod error {
733
732
734
733
#[ cfg( test) ]
735
734
mod tests {
736
- use crate :: handlers:: http:: logstream:: error:: StreamError ;
737
- use crate :: handlers:: http:: logstream:: get_stats;
738
- use crate :: handlers:: http:: modal:: utils:: logstream_utils:: PutStreamHeaders ;
739
- use actix_web:: test:: TestRequest ;
740
- use actix_web:: web;
735
+ use actix_web:: { test:: TestRequest , web} ;
741
736
use anyhow:: bail;
742
737
738
+ use crate :: handlers:: http:: modal:: utils:: logstream_utils:: PutStreamHeaders ;
739
+
740
+ use super :: * ;
741
+
743
742
// TODO: Fix this test with routes
744
743
// #[actix_web::test]
745
744
// #[should_panic]
@@ -750,7 +749,12 @@ mod tests {
750
749
751
750
#[ actix_web:: test]
752
751
async fn get_stats_stream_not_found_error_for_unknown_logstream ( ) -> anyhow:: Result < ( ) > {
753
- match get_stats ( web:: Path :: from ( "test" . to_string ( ) ) , None ) . await {
752
+ match get_stats (
753
+ web:: Path :: from ( "test" . to_string ( ) ) ,
754
+ Query ( StatsParams { date : None } ) ,
755
+ )
756
+ . await
757
+ {
754
758
Err ( StreamError :: StreamNotFound ( _) ) => Ok ( ( ) ) ,
755
759
_ => bail ! ( "expected StreamNotFound error" ) ,
756
760
}
0 commit comments