Skip to content

Commit 6b0b05e

Browse files
committed
Fixes
1 parent 722336b commit 6b0b05e

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

plugin-server/src/property-defs/property-defs-consumer.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export class PropertyDefsConsumer {
8484
protected promises: Set<Promise<any>> = new Set()
8585

8686
constructor(private hub: Hub) {
87-
// The group and topic are configurable allowing for multiple ingestion consumers to be run in parallel
8887
this.groupId = hub.PROPERTY_DEFS_CONSUMER_GROUP_ID
8988
this.topic = hub.PROPERTY_DEFS_CONSUMER_CONSUME_TOPIC
9089
this.propertyDefsDB = new PropertyDefsDB(hub)
@@ -146,21 +145,24 @@ export class PropertyDefsConsumer {
146145
}
147146

148147
const teamsInBatch = this.extractTeamIds(parsedMessages)
149-
collected.knownTeamIds = await this.runInstrumented('resolveTeams', () =>
150-
Promise.resolve(this.resolveTeams(this.propertyDefsDB, teamsInBatch))
151-
)
152-
153148
const groupTeamsInBatch = this.extractGroupTeamIds(parsedMessages, collected.knownTeamIds)
154-
collected.resolvedTeamGroups = await this.runInstrumented('resolveGroupsForTeams', () =>
155-
Promise.resolve(this.resolveGroupsForTeams(this.propertyDefsDB, groupTeamsInBatch))
156-
)
149+
150+
const [knownTeamIds, resolvedTeamGroups] = await Promise.all([
151+
this.runInstrumented('resolveTeams', () => this.resolveTeams(this.propertyDefsDB, teamsInBatch)),
152+
this.runInstrumented('resolveGroupsForTeams', () =>
153+
this.resolveGroupsForTeams(this.propertyDefsDB, groupTeamsInBatch)
154+
),
155+
])
156+
157+
collected.knownTeamIds = knownTeamIds
158+
collected.resolvedTeamGroups = resolvedTeamGroups
157159

158160
console.log('🔁', `Event batch teams and group indices resolved`)
159161

160162
// extract and dedup event and property definitions
161-
void (await this.runInstrumented('derivePropDefs', () =>
163+
await this.runInstrumented('derivePropDefs', () =>
162164
Promise.resolve(this.extractPropertyDefinitions(parsedMessages, collected))
163-
))
165+
)
164166

165167
console.log('🔁', `Property definitions collected`, JSON.stringify(collected, null, 2))
166168

plugin-server/src/property-defs/services/property-defs-db.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ export class PropertyDefsDB {
100100
async resolveGroupsForTeams(teamIds: number[]): Promise<TeamGroupRow[]> {
101101
const result = await this.hub.postgres.query<TeamGroupRow>(
102102
PostgresUse.COMMON_READ,
103-
`SELECT pt.id AS team_id, pgtm.group_type AS group_name, pgtm.group_type_index AS group_index FROM posthog_team
104-
INNER JOIN posthog.grouptypemapping AS pgtm ON pt.id = pgtm.team_id
105-
WHERE id = ANY ($1)`,
103+
`SELECT team_ids, group_type_index FROM posthog_grouptype WHERE team_ids = ANY ($1)`,
106104
[teamIds],
107105
'findTeamIds'
108106
)

0 commit comments

Comments
 (0)