Skip to content

Commit dc4ba4a

Browse files
add time partition to home api response
1 parent fa30263 commit dc4ba4a

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/prism/home/mod.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ use crate::{
4040
users::{dashboards::DASHBOARDS, filters::FILTERS},
4141
};
4242

43-
type StreamMetadataResponse =
44-
Result<(String, Vec<ObjectStoreFormat>, TelemetryType), PrismHomeError>;
43+
type StreamMetadataResponse = Result<
44+
(
45+
String,
46+
Vec<ObjectStoreFormat>,
47+
TelemetryType,
48+
Option<String>,
49+
),
50+
PrismHomeError,
51+
>;
4552

4653
#[derive(Debug, Serialize, Default)]
4754
pub struct DatedStats {
@@ -55,6 +62,8 @@ pub struct DatedStats {
5562
pub struct DataSet {
5663
title: String,
5764
dataset_type: TelemetryType,
65+
#[serde(skip_serializing_if = "Option::is_none")]
66+
time_partition: Option<String>,
5867
}
5968

6069
#[derive(Debug, Serialize)]
@@ -120,7 +129,7 @@ pub async fn generate_home_response(
120129

121130
for result in stream_metadata_results {
122131
match result {
123-
Ok((stream, metadata, dataset_type)) => {
132+
Ok((stream, metadata, dataset_type, time_partition)) => {
124133
// Skip internal streams if the flag is false
125134
if !include_internal
126135
&& metadata
@@ -133,6 +142,7 @@ pub async fn generate_home_response(
133142
datasets.push(DataSet {
134143
title: stream,
135144
dataset_type,
145+
time_partition,
136146
});
137147
}
138148
Err(e) => {
@@ -204,7 +214,15 @@ fn get_top_5_streams_by_ingestion(
204214

205215
async fn get_stream_metadata(
206216
stream: String,
207-
) -> Result<(String, Vec<ObjectStoreFormat>, TelemetryType), PrismHomeError> {
217+
) -> Result<
218+
(
219+
String,
220+
Vec<ObjectStoreFormat>,
221+
TelemetryType,
222+
Option<String>,
223+
),
224+
PrismHomeError,
225+
> {
208226
let path = RelativePathBuf::from_iter([&stream, STREAM_ROOT_DIRECTORY]);
209227
let obs = PARSEABLE
210228
.storage
@@ -234,8 +252,9 @@ async fn get_stream_metadata(
234252
}
235253

236254
let dataset_type = stream_jsons[0].telemetry_type;
255+
let time_partition = stream_jsons[0].time_partition.clone();
237256

238-
Ok((stream, stream_jsons, dataset_type))
257+
Ok((stream, stream_jsons, dataset_type, time_partition))
239258
}
240259

241260
async fn stats_for_date(

0 commit comments

Comments
 (0)