Skip to content
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

Prepare workspace for search features at creation #7467

Merged
merged 6 commits into from
Oct 7, 2024

Conversation

ijreilly
Copy link
Collaborator

@ijreilly ijreilly commented Oct 7, 2024

Enabling feature flags IsSearchEnabled and IsWorkspaceMigratedForSearch at workspace creation to ensure workspaces have the searchVector fields and indexes created.
For the feature to be enabled in the front-end we will also need IsQueryRunnerTwentyORMEnabled to be enabled but that is an independent topic.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request introduces changes to enable search-related feature flags during workspace creation, enhancing the search functionality for new workspaces.

  • Added enableDefaultFeatureFlags method in WorkspaceService to set search-related feature flags upon workspace activation
  • Created new file default-feature-flags.ts defining DEFAULT_FEATURE_FLAGS array with IsSearchEnabled and IsWorkspaceMigratedForSearch flags
  • Imported FeatureFlagModule in workspace.module.ts to support feature flag functionality
  • Modified WorkspaceService constructor to inject FeatureFlagEntity repository for managing feature flags
  • Note: IsQueryRunnerTwentyORMEnabled flag, required for front-end functionality, is not included in this update

3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM @ijreilly

@@ -152,4 +158,14 @@ export class WorkspaceService extends TypeOrmQueryService<Workspace> {
);
}
}

private async enableDefaultFeatureFlags(workspaceId: string) {
DEFAULT_FEATURE_FLAGS.forEach(async (featureFlagKey) => {
Copy link
Member

Choose a reason for hiding this comment

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

You can do a batch insert by passing an array instead of calling save n times 👍

    await this.featureFlagRepository.save(
      DEFAULT_FEATURE_FLAGS.map((featureFlagKey) => ({
        key: featureFlagKey,
        value: true,
        workspaceId,
      })),
    );

workspaceId: string,
) {
await this.featureFlagRepository.save({
key: featureFlagKey,
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious about this one, if we don't have a unicity constraint on the key (which I think we don't), won't it insert multiple times the same key (with false and true potentially), this could lead to issues during the fetch (if we get the first one for example)

Copy link
Member

Choose a reason for hiding this comment

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

Should be fine since you check before calling this function. However this function is called "enableFeatureFlag" so it might get confusing? Wdyt? Also should we move this to featureFlagService?

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM

@ijreilly ijreilly merged commit 9403160 into main Oct 7, 2024
7 of 8 checks passed
@ijreilly ijreilly deleted the search-at-workspace-creation branch October 7, 2024 13:29
harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
Enabling feature flags IsSearchEnabled and IsWorkspaceMigratedForSearch
at workspace creation to ensure workspaces have the searchVector fields
and indexes created.
For the feature to be enabled in the front-end we will also need
IsQueryRunnerTwentyORMEnabled to be enabled but that is an independent
topic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants