Skip to content

Commit 2fb8c0b

Browse files
update: ingestion=true/false in home api (#1531)
1 parent ac05480 commit 2fb8c0b

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/prism/home/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type StreamMetadataResponse = Result<
4444
TelemetryType,
4545
Option<String>,
4646
LogSource,
47+
bool,
4748
),
4849
PrismHomeError,
4950
>;
@@ -56,6 +57,7 @@ pub struct DataSet {
5657
#[serde(skip_serializing_if = "Option::is_none")]
5758
time_partition: Option<String>,
5859
dataset_format: LogSource,
60+
ingestion: bool,
5961
}
6062

6163
#[derive(Debug, Serialize, Deserialize, Default)]
@@ -124,7 +126,7 @@ pub async fn generate_home_response(
124126

125127
for result in stream_metadata_results {
126128
match result {
127-
Ok((stream, metadata, dataset_type, time_partition, dataset_format)) => {
129+
Ok((stream, metadata, dataset_type, time_partition, dataset_format, ingestion)) => {
128130
// Skip internal streams if the flag is false
129131
if !include_internal
130132
&& metadata
@@ -139,6 +141,7 @@ pub async fn generate_home_response(
139141
dataset_type,
140142
time_partition,
141143
dataset_format,
144+
ingestion,
142145
});
143146
}
144147
Err(e) => {
@@ -149,7 +152,7 @@ pub async fn generate_home_response(
149152
}
150153

151154
// Generate checklist and count triggered alerts
152-
let data_ingested = !all_streams.is_empty();
155+
let data_ingested = datasets.iter().any(|d| d.ingestion);
153156
let user_count = users().len();
154157
let user_added = user_count > 1; // more than just the default admin user
155158

@@ -195,6 +198,7 @@ async fn get_stream_metadata(
195198
TelemetryType,
196199
Option<String>,
197200
LogSource,
201+
bool,
198202
),
199203
PrismHomeError,
200204
> {
@@ -230,13 +234,17 @@ async fn get_stream_metadata(
230234
.unwrap_or_else(LogSourceEntry::default)
231235
.log_source_format
232236
.clone();
237+
let ingested = stream_jsons
238+
.iter()
239+
.any(|s| s.stats.current_stats.events > 0);
233240

234241
Ok((
235242
stream,
236243
stream_jsons,
237244
dataset_type,
238245
time_partition,
239246
dataset_format,
247+
ingested,
240248
))
241249
}
242250

0 commit comments

Comments
 (0)