Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

onboarding_steps: Use bulk_create for copying onboarding steps.

Tim Abbottad288f020cb5
diff --git a/zerver/lib/onboarding_steps.py b/zerver/lib/onboarding_steps.py
index 01f2f60f7df..c76512f474f 100644
--- a/zerver/lib/onboarding_steps.py
+++ b/zerver/lib/onboarding_steps.py
@@ -97,9 +97,14 @@ def get_next_onboarding_steps(user: UserProfile) -> list[APIOnboardingStep]:
def copy_onboarding_steps(source_profile: UserProfile, target_profile: UserProfile) -> None:
- for onboarding_step in frozenset(OnboardingStep.objects.filter(user=source_profile)):
- OnboardingStep.objects.create(
- user=target_profile,
- onboarding_step=onboarding_step.onboarding_step,
- timestamp=onboarding_step.timestamp,
- )
+ source_steps = OnboardingStep.objects.filter(user=source_profile)
+ OnboardingStep.objects.bulk_create(
+ [
+ OnboardingStep(
+ user=target_profile,
+ onboarding_step=step.onboarding_step,
+ timestamp=step.timestamp,
+ )
+ for step in source_steps
+ ]
+ )