Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(storage): update key creation to use key_of_parts

Steven Enamakel87bba55426e2
diff --git a/crates/openhuman-core/src/desktop/notifications/storage_schema.rs b/crates/openhuman-core/src/desktop/notifications/storage_schema.rs
index 31d1c6544f..78d206429a 100644
--- a/crates/openhuman-core/src/desktop/notifications/storage_schema.rs
+++ b/crates/openhuman-core/src/desktop/notifications/storage_schema.rs
@@ -15,10 +15,10 @@
use anyhow::Result;
use serde_json::Value;
-use tinystoragedrivers::{CollectionSpec, IndexSpec, Key};
+use tinystoragedrivers::{CollectionSpec, IndexSpec};
use crate::storage::schema_support::{
- key_of, map_legacy_collection, time_ms, Body, LegacySourceRecord as SourceRecord,
+ key_of, key_of_parts, map_legacy_collection, time_ms, Body, LegacySourceRecord as SourceRecord,
LegacyTargetRecord as TargetRecord,
};
@@ -84,10 +84,8 @@ pub(super) fn legacy_collections() -> Vec<CollectionSpec> {
/// Never in practice: a two-part key is valid.
pub(super) fn core_id(workspace: &str, event_id: &str) -> String {
#[allow(clippy::expect_used)]
- Key::of([workspace, event_id])
+ key_of_parts([workspace, event_id])
.expect("a two-part key is valid")
- .as_str()
- .to_owned()
}
fn integration_v2(batch: Vec<SourceRecord>) -> Result<Vec<TargetRecord>> {
diff --git a/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs b/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs
index d37e502142..48e5a79f36 100644
--- a/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/storage_schema.rs
@@ -12,10 +12,10 @@
use anyhow::Result;
use serde_json::Value;
-use tinystoragedrivers::{CollectionSpec, IndexSpec, Key};
+use tinystoragedrivers::{CollectionSpec, IndexSpec};
use crate::storage::schema_support::{
- key_of, map_legacy_collection, time_ms, Body, LegacySourceRecord as SourceRecord,
+ key_of, key_of_parts, map_legacy_collection, time_ms, Body, LegacySourceRecord as SourceRecord,
LegacyTargetRecord as TargetRecord,
};
@@ -61,10 +61,8 @@ pub(super) fn legacy_collections() -> Vec<CollectionSpec> {
/// Never in practice: a two-part key is valid.
pub(super) fn ingested_id(source_id: &str, external_id: &str) -> String {
#[allow(clippy::expect_used)]
- Key::of([source_id, external_id])
+ key_of_parts([source_id, external_id])
.expect("a two-part key is valid")
- .as_str()
- .to_owned()
}
fn sources_v2(batch: Vec<SourceRecord>) -> Result<Vec<TargetRecord>> {
diff --git a/crates/openhuman-core/src/profiles/storage_schema.rs b/crates/openhuman-core/src/profiles/storage_schema.rs
index f481a82fe7..73f4d8ce41 100644
--- a/crates/openhuman-core/src/profiles/storage_schema.rs
+++ b/crates/openhuman-core/src/profiles/storage_schema.rs
@@ -14,10 +14,10 @@
use anyhow::Result;
use serde_json::Value;
-use tinystoragedrivers::{CollectionSpec, Key, Storage};
+use tinystoragedrivers::{CollectionSpec, Storage};
use crate::storage::schema_support::{
- key_of, map_legacy_collection, Body, LegacySourceRecord as SourceRecord,
+ key_of, key_of_parts, map_legacy_collection, Body, LegacySourceRecord as SourceRecord,
LegacyTargetRecord as TargetRecord,
};
@@ -115,9 +115,7 @@ pub(crate) fn upgrade_lease_records(
}
Ok(TargetRecord::new(
"openhuman.leases",
- Key::of(["profiles", record.id.as_str()])?
- .as_str()
- .to_owned(),
+ key_of_parts(["profiles", record.id.as_str()])?,
Value::Object(body),
))
})