-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save Organization.available_features as a DB column #4426
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! minor comments
from posthog.models.organization import Organization | ||
|
||
|
||
def sync_all_organization_available_features() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: naming sync_all_organizations_available_features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of "Sync all Organization.available_features
", I think I'll leave as is
@receiver(models.signals.pre_save, sender=Organization) | ||
def organization_about_to_be_created(sender, instance: Organization, raw, using, **kwargs): | ||
if instance._state.adding: | ||
instance.update_available_features() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth just updating this particular org?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYM? That does seem to be the case already?
This reverts commit 421e854.
Changes
Closes #4408 (a prerequisite for PostHog/plugin-server#235).
Makes
Organization.available_features
a model field (Postgres column) instead of a dynamically calculated property. This way the features-determination logic only has to run occasionally, and the results are available in the database, so the plugin server can use them too.The field is updated (with
organization.update_available_features()
) in the following circumstances:Checklist