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

Commit e6fffd8

Browse files
committed
fix ta_finish_upload
1 parent 89a86c9 commit e6fffd8

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

services/test_analytics/ta_finish_upload.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from asgiref.sync import async_to_sync
66
from shared.celery_config import cache_test_rollups_task_name, process_flakes_task_name
77
from shared.django_apps.reports.models import ReportSession, UploadError
8+
from shared.helpers.redis import get_redis_connection
89
from shared.reports.types import UploadType
910
from shared.typings.torngit import AdditionalData
1011
from shared.yaml import UserYaml
@@ -14,7 +15,6 @@
1415
from database.models import Commit, Repository
1516
from helpers.notifier import NotifierResult
1617
from helpers.string import shorten_file_paths
17-
from services.redis import get_redis_connection
1818
from services.repository import (
1919
fetch_and_update_pull_request_information_from_commit,
2020
get_repo_provider_service,
@@ -44,7 +44,7 @@
4444
log = logging.getLogger(__name__)
4545

4646

47-
def get_upload_ids(commitid: str) -> dict[int, ReportSession]:
47+
def get_relevant_upload_ids(commitid: str) -> dict[int, ReportSession]:
4848
return {
4949
upload.id: upload
5050
for upload in ReportSession.objects.filter(
@@ -55,7 +55,11 @@ def get_upload_ids(commitid: str) -> dict[int, ReportSession]:
5555

5656

5757
def get_upload_error(upload_ids: list[int]) -> ErrorPayload | None:
58-
error = UploadError.objects.filter(report_session_id__in=upload_ids).first()
58+
error = (
59+
UploadError.objects.filter(report_session_id__in=upload_ids)
60+
.order_by("created_at")
61+
.first()
62+
)
5963
if error:
6064
return ErrorPayload(
6165
error_code=error.error_code,
@@ -151,7 +155,7 @@ def new_impl(
151155
"queue_notify": False,
152156
}
153157

154-
upload_ids = get_upload_ids(commitid)
158+
upload_ids = get_relevant_upload_ids(commitid)
155159
error = get_upload_error(list(upload_ids.keys()))
156160

157161
with read_tests_totals_summary.labels(impl="new").time():

0 commit comments

Comments
 (0)