55from asgiref .sync import async_to_sync
66from shared .celery_config import cache_test_rollups_task_name , process_flakes_task_name
77from shared .django_apps .reports .models import ReportSession , UploadError
8+ from shared .helpers .redis import get_redis_connection
89from shared .reports .types import UploadType
910from shared .typings .torngit import AdditionalData
1011from shared .yaml import UserYaml
1415from database .models import Commit , Repository
1516from helpers .notifier import NotifierResult
1617from helpers .string import shorten_file_paths
17- from services .redis import get_redis_connection
1818from services .repository import (
1919 fetch_and_update_pull_request_information_from_commit ,
2020 get_repo_provider_service ,
4444log = 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
5757def 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