use std::collections::BTreeMap;
use rustc_hash::FxHashSet;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
pub struct SeriesCount {
#[schemars(example = 3141)]
pub distinct_series: usize,
#[schemars(example = 21000)]
pub total_endpoints: usize,
#[schemars(example = 5000)]
pub lazy_endpoints: usize,
#[schemars(example = 16000)]
pub stored_endpoints: usize,
#[serde(skip)]
seen: FxHashSet<String>,
}
impl SeriesCount {
pub fn add_endpoint(&mut self, name: &str, is_lazy: bool) {
self.total_endpoints += 1;
if is_lazy {
self.lazy_endpoints += 1;
} else {
self.stored_endpoints += 1;
}
if self.seen.insert(name.to_string()) {
self.distinct_series += 1;
}
}
}
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
pub struct DetailedSeriesCount {
#[serde(flatten)]
pub total: SeriesCount,
pub by_db: BTreeMap<String, SeriesCount>,
}