Skip to content

Commit 800118b

Browse files
fix: add start and end timestamp to counts api response (#1109)
new structure of records in response json to /counts api ``` { "counts_start_timestamp": "2025-01-16T17:34:00+00:00", "counts_end_timestamp": "2025-01-16T17:47:00+00:00", "log_count": 4203450 } ```
1 parent 15b903e commit 800118b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/handlers/http/query.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ pub async fn get_counts(
164164
let records = counts_request.get_bin_density().await?;
165165

166166
Ok(web::Json(CountsResponse {
167-
fields: vec!["counts_timestamp".into(), "log_count".into()],
167+
fields: vec![
168+
"counts_start_timestamp".into(),
169+
"counts_end_timestamp".into(),
170+
"log_count".into(),
171+
],
168172
records,
169173
}))
170174
}

src/query/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ impl Query {
248248
#[derive(Debug, Serialize, Clone)]
249249
pub struct CountsRecord {
250250
/// Start time of the bin
251-
pub counts_timestamp: String,
251+
pub counts_start_timestamp: String,
252+
/// End time of the bin
253+
pub counts_end_timestamp: String,
252254
/// Number of logs in the bin
253255
pub log_count: u64,
254256
}
@@ -297,8 +299,8 @@ impl CountsRequest {
297299

298300
for bin in counts {
299301
// extract start and end time to compare
300-
let counts_timestamp = bin.start.timestamp_millis();
301-
302+
let counts_start_timestamp = bin.start.timestamp_millis();
303+
let counts_end_timestamp = bin.end.timestamp_millis();
302304
// Sum up the number of rows that fall within the bin
303305
let log_count: u64 = all_manifest_files
304306
.iter()
@@ -322,7 +324,10 @@ impl CountsRequest {
322324
.sum();
323325

324326
counts_records.push(CountsRecord {
325-
counts_timestamp: DateTime::from_timestamp_millis(counts_timestamp)
327+
counts_start_timestamp: DateTime::from_timestamp_millis(counts_start_timestamp)
328+
.unwrap()
329+
.to_rfc3339(),
330+
counts_end_timestamp: DateTime::from_timestamp_millis(counts_end_timestamp)
326331
.unwrap()
327332
.to_rfc3339(),
328333
log_count,

0 commit comments

Comments
 (0)