Skip to content

Commit

Permalink
fix(propdefs): fix group-type caching (#24930)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverb123 authored Sep 12, 2024
1 parent 9580ac6 commit ff85013
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rust/property-defs-rs/src/app_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ impl AppContext {
continue;
};
// If we didn't find a group type, we have nothing to resolve.
let Some(GroupType::Unresolved(name)) = &update.group_type_index else {
let Some(GroupType::Unresolved(group_name)) = &update.group_type_index else {
continue;
};

let name = format!("{}:{}", update.team_id, name);
let cache_key = format!("{}:{}", update.team_id, group_name);

let cached = self.group_type_cache.get(&name);
let cached = self.group_type_cache.get(&cache_key);
if let Some(index) = cached {
update.group_type_index =
update.group_type_index.take().map(|gti| gti.resolve(index));
Expand All @@ -109,14 +109,14 @@ impl AppContext {

let found = sqlx::query_scalar!(
"SELECT group_type_index FROM posthog_grouptypemapping WHERE group_type = $1 AND team_id = $2",
name,
group_name,
update.team_id
)
.fetch_optional(&self.pool)
.await?;

if let Some(index) = found {
self.group_type_cache.insert(name, index);
self.group_type_cache.insert(cache_key, index);
update.group_type_index =
update.group_type_index.take().map(|gti| gti.resolve(index));
} else {
Expand Down

0 comments on commit ff85013

Please sign in to comment.