Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Reorient ActionManager to group by teamId for practicality - #433

Merged
Twixes merged 7 commits into
masterfrom
actionmanager-reoriented
May 27, 2021
Merged

Reorient ActionManager to group by teamId for practicality#433
Twixes merged 7 commits into
masterfrom
actionmanager-reoriented

Conversation

@Twixes

@Twixes Twixes commented May 26, 2021

Copy link
Copy Markdown
Member

Changes

Followup to #403, makes ActionManager more practical for the actual matching engine.

Checklist

  • Jest tests

@Twixes
Twixes requested a review from neilkakkar May 26, 2021 21:05
@Twixes Twixes mentioned this pull request May 27, 2021
26 tasks
Comment thread src/worker/ingestion/action-manager.ts Outdated
public async reloadAllActions(): Promise<void> {
this.actionCache = await this.db.fetchAllActionsMap()
this.actionCache = Object.fromEntries(
Object.entries(groupBy(await this.db.fetchAllActions(), 'team_id')).map(([teamId, actions]) => [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you expect db.fetchAllActions() to be used elsewhere? If not, I think it makes things a lot simpler to just have db.fetchAllActionsByTeam() which returns them grouped by team?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 That's sensible

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I was a bit unclear: I meant fetchAllActionsGroupedByTeam to replace fetchAllActions (which means getting rid of all the groupBy logic, since we're building the grouping from scratch, just like in fetchAllActions() right now.

Thoughts?

@Twixes Twixes May 27, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you mean, done. Though maybe I'll leave groupBy in utils since maybe it'll come in useful and I've already written it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works!

@mariusandra mariusandra May 27, 2021

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"maybe it'll come in useful"

... is a dangerous thing to say :D. See for example the HTTP server (let's remove it) :).

@Twixes Twixes May 27, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, yeah. Well, at least it's isolated and tested. Unlike the HTTP server… pending removal in #282 for some time now

@Twixes
Twixes requested a review from neilkakkar May 27, 2021 10:32

@neilkakkar neilkakkar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few red tests, but otherwise LGTM

@Twixes
Twixes merged commit 34c14e1 into master May 27, 2021
@Twixes
Twixes deleted the actionmanager-reoriented branch May 27, 2021 10:55
fuziontech pushed a commit to PostHog/posthog that referenced this pull request Oct 12, 2021
…cticality (PostHog/plugin-server#433)

* Reorient `ActionManager` to group by teamId for practicality

* Make `getTeamActions()` return type more versatile

* Fix PubSub's lack of teamId

* Add DB.fetchAllActionsGroupedByTeam

* Address feedback
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants