@@ -146,24 +146,18 @@ pub async fn put_stream(req: HttpRequest, body: Bytes) -> Result<impl Responder,
146146 } ) ;
147147 }
148148
149-
150- if !body. is_empty ( ) {
151- if static_schema_flag == "true" {
152- let body_str = std:: str:: from_utf8 ( & body) . unwrap ( ) ;
153- let static_schema: StaticSchema = serde_json:: from_str ( body_str) . unwrap ( ) ;
154- let parsed_schema = convert_static_schema_to_arrow_schema ( static_schema) ;
155- if let Ok ( parsed_schema) = parsed_schema {
156- schema = parsed_schema;
157- } else {
158- return Err ( StreamError :: Custom {
159- msg : format ! (
160- "unable to commit static schema, logstream {stream_name} not created"
161- ) ,
162- status : StatusCode :: BAD_REQUEST ,
163- } ) ;
164- }
149+ if !body. is_empty ( ) && static_schema_flag == "true" {
150+ let static_schema: StaticSchema = serde_json:: from_slice ( & body) . unwrap ( ) ;
151+ let parsed_schema = convert_static_schema_to_arrow_schema ( static_schema) ;
152+ if let Ok ( parsed_schema) = parsed_schema {
153+ schema = parsed_schema;
154+ } else {
155+ return Err ( StreamError :: Custom {
156+ msg : format ! ( "unable to commit static schema, logstream {stream_name} not created" ) ,
157+ status : StatusCode :: BAD_REQUEST ,
158+ } ) ;
165159 }
166- } else if static_schema_flag == "true" {
160+ } else if body . is_empty ( ) && static_schema_flag == "true" {
167161 return Err ( StreamError :: Custom {
168162 msg : format ! (
169163 "please provide schema in the request body for static schema logstream {stream_name}"
@@ -172,9 +166,9 @@ pub async fn put_stream(req: HttpRequest, body: Bytes) -> Result<impl Responder,
172166 } ) ;
173167 }
174168
175- // ! broken
169+
176170 if CONFIG . parseable . mode == Mode :: Query {
177- sync_streams_with_ingesters ( & stream_name) . await ?;
171+ sync_streams_with_ingesters ( & stream_name, time_partition , static_schema_flag , body ) . await ?;
178172 }
179173 create_stream ( stream_name, time_partition, static_schema_flag, schema) . await ?;
180174
@@ -333,23 +327,8 @@ pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError>
333327
334328 let time = Utc :: now ( ) ;
335329
336- /* // ! broken / update
337- let stats = serde_json::json!({
338- "stream": stream_name,
339- "time": time,
340- "ingestion": {
341- "count": stats.events,
342- "size": format!("{} {}", stats.ingestion, "Bytes"),
343- "format": "json"
344- },
345- "storage": {
346- "size": format!("{} {}", stats.storage, "Bytes"),
347- "format": "parquet"
348- }
349- });
350- */
351330 let stats = match & stream_meta. first_event_at {
352- Some ( first_event_at ) => {
331+ Some ( _ ) => {
353332 let ingestion_stats = IngestionStats :: new (
354333 stats. events ,
355334 format ! ( "{} {}" , stats. ingestion, "Bytes" ) ,
@@ -358,14 +337,7 @@ pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError>
358337 let storage_stats =
359338 StorageStats :: new ( format ! ( "{} {}" , stats. storage, "Bytes" ) , "parquet" ) ;
360339
361- QueriedStats :: new (
362- & stream_name,
363- & stream_meta. created_at ,
364- Some ( first_event_at. to_owned ( ) ) ,
365- time,
366- ingestion_stats,
367- storage_stats,
368- )
340+ QueriedStats :: new ( & stream_name, time, ingestion_stats, storage_stats)
369341 }
370342
371343 None => {
@@ -377,14 +349,7 @@ pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError>
377349 let storage_stats =
378350 StorageStats :: new ( format ! ( "{} {}" , stats. storage, "Bytes" ) , "parquet" ) ;
379351
380- QueriedStats :: new (
381- & stream_name,
382- & stream_meta. created_at ,
383- None ,
384- time,
385- ingestion_stats,
386- storage_stats,
387- )
352+ QueriedStats :: new ( & stream_name, time, ingestion_stats, storage_stats)
388353 }
389354 } ;
390355 let stats = if let Some ( mut ingester_stats) = ingester_stats {
@@ -505,6 +470,8 @@ pub async fn get_stream_info(req: HttpRequest) -> Result<impl Responder, StreamE
505470 static_schema_flag : stream_meta. static_schema_flag . clone ( ) ,
506471 } ;
507472
473+ // get the other info from
474+
508475 Ok ( ( web:: Json ( stream_info) , StatusCode :: OK ) )
509476}
510477
0 commit comments