From 83560a03d2eaed371c7b97911ce8ed959f63cbaf Mon Sep 17 00:00:00 2001 From: Nasr Date: Thu, 31 Oct 2024 16:17:17 -0400 Subject: [PATCH] idx modesl for multiple names --- src/wasm/types.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wasm/types.rs b/src/wasm/types.rs index 7a88a02..a616da4 100644 --- a/src/wasm/types.rs +++ b/src/wasm/types.rs @@ -124,7 +124,17 @@ pub struct Entity(pub HashMap); impl From<&torii_grpc::types::schema::Entity> for Entity { fn from(value: &torii_grpc::types::schema::Entity) -> Self { - Self(value.models.iter().map(|m| (m.name.clone(), m.into())).collect()) + let mut seen_models = HashMap::new(); + Self(value.models.iter().map(|m| { + let count = seen_models.entry(m.name.clone()).or_insert(0); + let name = if *count == 0 { + m.name.clone() + } else { + format!("{}-{}", m.name, count) + }; + *count += 1; + (name, m.into()) + }).collect()) } }