Skip to content

Commit e15730c

Browse files
ref(quick-start): Replace 'record' with 'create_or_update' in 'record_new_project' (#86663)
1 parent b7bf581 commit e15730c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/sentry/receivers/onboarding.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,17 @@ def record_new_project(project, user=None, user_id=None, origin=None, **kwargs):
9898
),
9999
)
100100

101-
success = OrganizationOnboardingTask.objects.record(
101+
_, created = OrganizationOnboardingTask.objects.create_or_update(
102102
organization_id=project.organization_id,
103103
task=OnboardingTask.FIRST_PROJECT,
104-
user_id=user_id,
105-
status=OnboardingTaskStatus.COMPLETE,
106-
project_id=project.id,
104+
values={
105+
"user_id": user_id,
106+
"status": OnboardingTaskStatus.COMPLETE,
107+
"project_id": project.id,
108+
},
107109
)
108-
if not success:
110+
# if we updated the task "first project", it means that it already exists and now we want to create the task "second platform"
111+
if not created:
109112
# Check if the "first project" task already exists and log an error if needed
110113
first_project_task_exists = OrganizationOnboardingTask.objects.filter(
111114
organization_id=project.organization_id, task=OnboardingTask.FIRST_PROJECT
@@ -117,12 +120,14 @@ def record_new_project(project, user=None, user_id=None, origin=None, **kwargs):
117120
level="warning",
118121
)
119122

120-
OrganizationOnboardingTask.objects.record(
123+
OrganizationOnboardingTask.objects.create_or_update(
121124
organization_id=project.organization_id,
122125
task=OnboardingTask.SECOND_PLATFORM,
123-
user_id=user_id,
124-
status=OnboardingTaskStatus.COMPLETE,
125-
project_id=project.id,
126+
values={
127+
"user_id": user_id,
128+
"status": OnboardingTaskStatus.COMPLETE,
129+
"project_id": project.id,
130+
},
126131
)
127132
analytics.record(
128133
"second_platform.added",

0 commit comments

Comments
 (0)