Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions codecov/commands/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from core.commands.flag import FlagCommands
from core.commands.pull import PullCommands
from core.commands.repository import RepositoryCommands
from core.commands.upload import UploadCommands
from utils.services import get_long_service_name

mapping = {
Expand All @@ -17,7 +16,6 @@
"branch": BranchCommands,
"compare": CompareCommands,
"pull": PullCommands,
"upload": UploadCommands,
"flag": FlagCommands,
"component": ComponentCommands,
}
Expand Down
3 changes: 0 additions & 3 deletions core/commands/upload/__init__.py

This file was deleted.

Empty file.
16 changes: 0 additions & 16 deletions core/commands/upload/interactors/get_upload_error.py

This file was deleted.

Empty file.
74 changes: 0 additions & 74 deletions core/commands/upload/interactors/tests/test_upload_error.py

This file was deleted.

Empty file.
18 changes: 0 additions & 18 deletions core/commands/upload/tests/test_upload.py

This file was deleted.

8 changes: 0 additions & 8 deletions core/commands/upload/upload.py

This file was deleted.

25 changes: 1 addition & 24 deletions graphql_api/actions/commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from core.models import Commit, Pull, Repository
from graphql_api.types.enums import CommitStatus
from reports.models import CommitReport, ReportSession
from reports.models import CommitReport


def pull_commits(pull: Pull) -> QuerySet[Commit]:
Expand All @@ -23,29 +23,6 @@ def pull_commits(pull: Pull) -> QuerySet[Commit]:
return Commit.objects.filter(id__in=subquery).defer("_report")


def commit_uploads(commit: Commit) -> QuerySet[ReportSession]:
if not commit.commitreport:
return ReportSession.objects.none()

sessions = commit.commitreport.sessions.prefetch_related("flags")

# # sessions w/ flags and type 'uploaded'
# uploaded = sessions.filter(upload_type="uploaded")

# # carry forward flags that do not have an equivalent uploaded flag
# carried_forward = sessions.filter(upload_type="carriedforward").exclude(
# uploadflagmembership__flag_id__in=uploaded.values_list( <------------ FIXME: looks like `flag_id__in` is causing a seq scan in prod
# "uploadflagmembership__flag_id", flat=True
# )
# )

# return (uploaded.prefetch_related("flags")).union(
# carried_forward.prefetch_related("flags")
# )

return sessions


def commit_status(
commit: Commit, report_type: CommitReport.ReportType
) -> Optional[CommitStatus]:
Expand Down
17 changes: 15 additions & 2 deletions graphql_api/types/commit/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import services.path as path_service
from codecov_auth.models import Owner
from core.models import Commit
from graphql_api.actions.commits import commit_status, commit_uploads
from graphql_api.actions.commits import commit_status
from graphql_api.actions.comparison import validate_commit_comparison
from graphql_api.actions.path_contents import sort_path_contents
from graphql_api.dataloader.bundle_analysis import (
Expand All @@ -30,6 +30,7 @@
queryset_to_connection,
queryset_to_connection_sync,
)
from graphql_api.helpers.requested_fields import selected_fields
from graphql_api.types.comparison.comparison import (
MissingBaseCommit,
MissingHeadReport,
Expand Down Expand Up @@ -93,7 +94,19 @@ async def resolve_yaml_state(commit: Commit, info) -> YamlStates:
@commit_bindable.field("uploads")
@sync_to_async
def resolve_list_uploads(commit: Commit, info, **kwargs):
queryset = commit_uploads(commit)
if not commit.commitreport:
return queryset_to_connection_sync([])

queryset = commit.commitreport.sessions

requested_fields = selected_fields(info)

# the `requested_fields` here are prefixed with `edges.node`, as this is a `Connection`
# and using `uploads { edges { node { ... } } }` is the way this is queried.
if "edges.node.flags" in requested_fields:
queryset = queryset.prefetch_related("flags")
if "edges.node.errors" in requested_fields:
queryset = queryset.prefetch_related("errors")

if not kwargs: # temp to override kwargs -> return all current uploads
kwargs["first"] = queryset.count()
Expand Down
27 changes: 10 additions & 17 deletions graphql_api/types/upload/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from ariadne import ObjectType
from asgiref.sync import sync_to_async
from django.urls import reverse
from graphql import GraphQLResolveInfo
from shared.django_apps.utils.services import get_short_service_name

from graphql_api.helpers.connection import queryset_to_connection
from graphql_api.helpers.connection import queryset_to_connection_sync
from graphql_api.types.enums import (
OrderingDirection,
UploadErrorEnum,
UploadState,
UploadType,
Expand All @@ -26,43 +26,36 @@


@upload_bindable.field("state")
def resolve_state(upload, info):
def resolve_state(upload: ReportSession, info: GraphQLResolveInfo) -> UploadState:
if not upload.state:
return UploadState.ERROR
return UploadState(upload.state)


@upload_bindable.field("id")
def resolve_id(upload: ReportSession, info) -> Optional[int]:
def resolve_id(upload: ReportSession, info: GraphQLResolveInfo) -> Optional[int]:
return upload.order_number


@upload_bindable.field("uploadType")
def resolve_upload_type(upload, info) -> UploadType:
def resolve_upload_type(upload: ReportSession, info: GraphQLResolveInfo) -> UploadType:
return UploadType(upload.upload_type)


@upload_bindable.field("errors")
async def resolve_errors(report_session, info, **kwargs):
command = info.context["executor"].get_command("upload")
queryset = await command.get_upload_errors(report_session)
result = await queryset_to_connection(
queryset,
ordering=("updated_at",),
ordering_direction=OrderingDirection.ASC,
**kwargs,
)
return result
@sync_to_async
def resolve_errors(report_session: ReportSession, info: GraphQLResolveInfo, **kwargs):
return queryset_to_connection_sync(list(report_session.errors.all()))


@upload_error_bindable.field("errorCode")
def resolve_error_code(error, info):
def resolve_error_code(error, info: GraphQLResolveInfo) -> UploadErrorEnum:
return UploadErrorEnum(error.error_code)


@upload_bindable.field("ciUrl")
@sync_to_async
def resolve_ci_url(upload, info):
def resolve_ci_url(upload: ReportSession, info: GraphQLResolveInfo):
return upload.ci_url


Expand Down
1 change: 1 addition & 0 deletions timeseries/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ def test_no_dataset(self, trigger_backfill):
repository_id__in=[self.repo1.pk, self.repo2.pk],
)
)
datasets.reverse()
assert len(datasets) == 2
trigger_backfill.assert_called_once_with(datasets)

Expand Down
Loading