-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add option to synchronize all active workspaces at once #6221
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.
PR Summary
- Added
--sync-all-active-workspaces
option in/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.ts
- Introduced
isWorkspaceActive
utility in/packages/twenty-server/src/database/commands/utils/is-workspace-active.utils.ts
- Refactored workspace activity check in
/packages/twenty-server/src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command.ts
- Updated module imports in
/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts
to support new feature
4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
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.
PR Summary
(updates since last review)
- Enhanced
sync-workspace-metadata.command.ts
to support synchronizing all active workspaces. - Improved error handling and logging for bulk workspace synchronization.
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
@@ -81,7 +76,11 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends | |||
const activeWorkspaceIds = ( | |||
await Promise.all( | |||
workspaces.map(async (workspace) => { | |||
const isActive = await this.workspaceIsActive(workspace); | |||
const isActive = await isWorkspaceActive({ |
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.
move to workspace.service.ts
const workspaceIds = options.workspaceId ? [options.workspaceId] : []; | ||
let workspaceIds = options.workspaceId ? [options.workspaceId] : []; | ||
|
||
if (options.syncAllActiveWorkspaces && isEmpty(workspaceIds)) { |
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.
no need for onlyActiveWorkspaces
const activeWorkspaceIds = ( | ||
await Promise.all( | ||
workspaces.map(async (workspace) => { | ||
const isActive = await isWorkspaceActive({ |
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.
add areWorkspaceActive query
); | ||
} | ||
} catch (error) { | ||
if (options.syncAllActiveWorkspaces) { |
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.
if (options.throwOnFirstFail)
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.
PR Summary
(updates since last review)
- Added
getActiveWorkspaceIds
method inworkspace.service.ts
to fetch active workspace IDs - Updated
sync-workspace-metadata.command.ts
to synchronize all active workspaces - Replaced direct repository access with
WorkspaceService
in0-22-add-new-address-field-to-views-with-deprecated-address.command.ts
- Removed
is-workspace-active.utils.ts
file - Updated
workspace.service.ts
constructor to includeBillingSubscription
andFeatureFlagEntity
repositories
4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
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.
PR Summary
(updates since last review)
- Replaced
WorkspaceService
withWorkspaceStatusService
inpackages/twenty-server/src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command.ts
- Removed
getActiveWorkspaceIds
method frompackages/twenty-server/src/engine/core-modules/workspace/services/workspace.service.ts
- Added
WorkspaceStatusModule
topackages/twenty-server/src/engine/workspace-manager/workspace-manager.module.ts
- Introduced
WorkspaceStatusService
inpackages/twenty-server/src/engine/workspace-manager/workspace-status/services/workspace-status.service.ts
- Added option to synchronize all active workspaces in
packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.ts
9 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
const workspaces = await this.workspaceRepository.find(); | ||
const workspaceIds = workspaces.map((workspace) => workspace.id); |
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.
🪶 style: Fetching all workspaces without any filters could be inefficient for large datasets. Consider adding pagination or filtering.
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.
PR Summary
(updates since last review)
- Corrected import path for
WorkspaceStatusModule
inpackages/twenty-server/src/engine/workspace-manager/workspace-manager.module.ts
- Renamed
workspace-manager.module.ts
toworkspace-status.module.ts
inpackages/twenty-server/src/engine/workspace-manager/workspace-status/
- Updated imports to include
TypeOrmModule
withWorkspace
,BillingSubscription
, andFeatureFlagEntity
entities inworkspace-status.module.ts
- Ensured
WorkspaceStatusService
is provided inworkspace-status.module.ts
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
a0ad08c
to
abcf8e6
Compare
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.
PR Summary
(updates since last review)
- Added
WorkspaceStatusModule
todatabase-command.module.ts
imports - Enhanced
sync-workspace-metadata.command.ts
to sync all active workspaces usingWorkspaceStatusService
- Improved error handling and logging in
sync-workspace-metadata.command.ts
- Added
WorkspaceStatusModule
and removed unnecessary imports inworkspace-sync-metadata-commands.module.ts
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
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.
PR Summary
(updates since last review)
- Introduced check for 'IS_BILLING_ENABLED' in
workspace-status.service.ts
to filter active workspaces by billing status. - Added
EnvironmentModule
toWorkspaceStatusModule
imports inworkspace-manager.module.ts
. - Enhanced
sync-workspace-metadata.command.ts
to sync all active workspaces if no specific ID is provided. - Improved logging and error handling in
sync-workspace-metadata.command.ts
.
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
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!
In the longer term, we want to improve the efficiency and reliability of the sync-metadata command, by choosing an error handling strategy and paying greater attention to health checks.
In the meantime, this PR adds an option to run the sync-metadata command on all active workspaces at once.