Database schema optimization - part 8

This commit is contained in:
mdecimus
2025-11-07 18:50:39 +01:00
parent 73f09072ab
commit d9e6927606
44 changed files with 2003 additions and 849 deletions

View File

@@ -367,28 +367,29 @@ impl JmapConfig {
SearchIndex::Email,
SearchIndex::Contacts,
SearchIndex::Calendar,
SearchIndex::Tracing,
] {
let mut fields = AHashSet::new();
let todo = "implement";
/*for field_str in config.values(&format!(
"jmap.index.{}.fields",
index.as_config_case()
)) {
match SearchField::try_from(field_str.1.as_str()) {
Ok(field) => {
fields.insert(field);
}
Err(_) => {
config.new_parse_error(
&format!(
"jmap.index.{}.fields",
index.as_config_case()
),
format!("Invalid search field: {}", field_str.1),
);
}
}
}*/
let index_name = match index {
SearchIndex::Email => "email",
SearchIndex::Contacts => "contacts",
SearchIndex::Calendar => "calendar",
SearchIndex::Tracing => "tracing",
_ => unreachable!(),
};
if !config
.property_or_default::<bool>(&format!("jmap.index.{index_name}.enabled"), "true")
.unwrap_or(true)
{
continue;
}
for (_, field) in
config.properties::<SearchField>(&format!("jmap.index.{index_name}.fields"))
{
fields.insert(field);
}
jmap.index_fields.insert(index, fields);
}

View File

@@ -98,7 +98,6 @@ pub struct WebhookTracer {
#[cfg(feature = "enterprise")]
pub struct StoreTracer {
pub store: store::Store,
pub indexed: bool,
}
// SPDX-SnippetEnd
@@ -538,9 +537,6 @@ impl Tracers {
lossy: false,
typ: TelemetrySubscriberType::StoreTracer(StoreTracer {
store: store.clone(),
indexed: config
.property_or_default("tracing.history.indexed", "false")
.unwrap_or(false),
}),
};

View File

@@ -53,30 +53,27 @@ pub(crate) fn spawn_store_tracer(builder: SubscriberBuilder, settings: StoreTrac
.any(|(k, v)| matches!((k, v), (Key::QueueId, Value::UInt(_))))
{
// Serialize events
batch.set(
ValueClass::Telemetry(TelemetryClass::Span { span_id }),
serialize_events(
[span.as_ref()]
.into_iter()
.chain(events.iter().map(|event| event.as_ref()))
.chain([event.as_ref()].into_iter()),
events.len() + 2,
),
);
if settings.indexed {
batch
.with_account_id((span_id >> 32) as u32) // TODO: This is hacky, improve
.with_document(span_id as u32)
.set(
ValueClass::TaskQueue(TaskQueueClass::UpdateIndex {
due: now,
index: SearchIndex::Tracing,
is_insert: true,
}),
vec![],
);
}
batch
.set(
ValueClass::Telemetry(TelemetryClass::Span { span_id }),
serialize_events(
[span.as_ref()]
.into_iter()
.chain(events.iter().map(|event| event.as_ref()))
.chain([event.as_ref()].into_iter()),
events.len() + 2,
),
)
.with_account_id((span_id >> 32) as u32) // TODO: This is hacky, improve
.with_document(span_id as u32)
.set(
ValueClass::TaskQueue(TaskQueueClass::UpdateIndex {
due: now,
index: SearchIndex::Tracing,
is_insert: true,
}),
vec![],
);
}
}
}