Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit efd2e1a

Browse files
committed
Use commit author falling back to special -1 id if does not exist
1 parent ca08f95 commit efd2e1a

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

upload/tests/views/test_bundle_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_upload_bundle_analysis_success(db, client, mocker, mock_redis):
110110
mock_amplitude.assert_called_with(
111111
"Upload Sent",
112112
{
113-
"user_ownerid": commit.repository.author.ownerid,
113+
"user_ownerid": commit.author.ownerid,
114114
"ownerid": commit.repository.author.ownerid,
115115
"repoid": commit.repository.repoid,
116116
"commitid": commit.id,

upload/tests/views/test_test_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_upload_test_results(db, client, mocker, mock_redis):
122122
mock_amplitude.assert_called_with(
123123
"Upload Sent",
124124
{
125-
"user_ownerid": commit.repository.author.ownerid,
125+
"user_ownerid": commit.author.ownerid,
126126
"ownerid": commit.repository.author.ownerid,
127127
"repoid": commit.repository.repoid,
128128
"commitid": commit.id,

upload/views/bundle_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def post(self, request: HttpRequest) -> Response:
224224
AmplitudeEventPublisher().publish(
225225
"Upload Sent",
226226
{
227-
"user_ownerid": repo.author.ownerid,
227+
"user_ownerid": commit.author.ownerid if commit.author else -1,
228228
"ownerid": repo.author.ownerid,
229229
"repoid": repo.repoid,
230230
"commitid": commit.id, # Not commit.commitid, we do not want a commit SHA here!

upload/views/test_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def post(self, request):
191191
AmplitudeEventPublisher().publish(
192192
"Upload Sent",
193193
{
194-
"user_ownerid": repo.author.ownerid,
194+
"user_ownerid": commit.author.ownerid if commit.author else -1,
195195
"ownerid": repo.author.ownerid,
196196
"repoid": repo.repoid,
197197
"commitid": commit.id, # Not commit.commitid, we do not want a commit SHA here!

upload/views/uploads.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,10 @@ def send_analytics_data(
171171
AmplitudeEventPublisher().publish(
172172
"Upload Sent",
173173
{
174-
# Attribute this event to the repo owner. For BA/TA uploads we
175-
# don't necessarily have the commit author at upload time, so to
176-
# align the upload events, we will always attribute uploads to the
177-
# repo owner. It's also not necessarily the case that the commit
178-
# author is the owner performing the 'Upload Sent' action.
179-
"user_ownerid": commit.repository.author.ownerid,
174+
"user_ownerid": commit.author.ownerid,
180175
"ownerid": commit.repository.author.ownerid,
181176
"repoid": commit.repository.repoid,
182-
"commitid": commit.id, # Not commit.commitid, we do not want a commit SHA here!
177+
"commitid": commit.id, # Not commit.commitid, we do not want a commit SHA here.
183178
"pullid": commit.pullid,
184179
"upload_type": "Coverage report",
185180
},

0 commit comments

Comments
 (0)