Skip to content

Commit

Permalink
fix: first_event_at response
Browse files Browse the repository at this point in the history
  • Loading branch information
Eshanatnight committed Mar 27, 2024
1 parent 81b241d commit b107341
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions server/src/handlers/http/logstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError>
)
}

// ? this case should not happen
None => {
let ingestion_stats = IngestionStats::new(
stats.events,
Expand All @@ -329,13 +328,14 @@ pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError>
QueriedStats::new(
&stream_name,
&stream_meta.created_at,
Some('0'.to_string()),
None,
time,
ingestion_stats,
storage_stats,
)
}
};

let stats = if let Some(mut ingestor_stats) = ingestor_stats {
ingestor_stats.push(stats);
QueryServer::merge_quried_stats(ingestor_stats)
Expand Down
10 changes: 6 additions & 4 deletions server/src/handlers/http/modal/query_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ impl QueryServer {
.iter()
.map(|x| x.creation_time.parse::<DateTime<Utc>>().unwrap())
.min()
.unwrap_or_default();
.unwrap();

// get the stream name
let stream_name = stats[0].stream.clone();
Expand All @@ -572,11 +572,13 @@ impl QueryServer {
let min_first_event_at = stats
.iter()
.map(|x| match x.first_event_at.as_ref() {
Some(fea) => fea.parse::<DateTime<Utc>>().unwrap_or_default(),
None => Utc::now(),
// we can directly unwrap here because we are sure
// that the string is a valid date time or is None
Some(fea) => fea.parse::<DateTime<Utc>>().unwrap(),
None => Utc::now(), // oldest possible date
})
.min()
.unwrap_or_else(Utc::now);
.unwrap(); // should never be None right

let min_time = stats.iter().map(|x| x.time).min().unwrap_or_else(Utc::now);

Expand Down

0 comments on commit b107341

Please sign in to comment.