Skip to content

Commit

Permalink
chore: reduce usage of PreProcess task (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
giovanni-guidini authored Sep 11, 2024
1 parent e8d8cd0 commit f6ed141
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
3 changes: 0 additions & 3 deletions rollouts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@ def owner_slug(owner: Owner) -> str:

__all__ = ["Feature"]

NO_PREPROCESS_UPLOAD = Feature("no_PreProcessUpload")


# By default, features have one variant:
# { "enabled": FeatureVariant(True, 1.0) }
6 changes: 3 additions & 3 deletions upload/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Meta:
)
fields = read_only_fields + ("code",)

def create(self, validated_data):
def create(self, validated_data) -> tuple[CommitReport, bool]:
report = (
CommitReport.objects.coverage_reports()
.filter(
Expand All @@ -174,8 +174,8 @@ def create(self, validated_data):
if report.report_type is None:
report.report_type = CommitReport.ReportType.COVERAGE
report.save()
return report
return super().create(validated_data)
return report, False
return super().create(validated_data), True


class ReportResultsSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 1 addition & 1 deletion upload/tests/views/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_create_report_already_exists(client, db, mocker):
assert CommitReport.objects.filter(
commit_id=commit.id, code="code", report_type=CommitReport.ReportType.COVERAGE
).exists()
mocked_call.assert_called_once()
mocked_call.assert_not_called()


def test_reports_post_code_as_default(client, db, mocker):
Expand Down
7 changes: 3 additions & 4 deletions upload/views/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
repo_auth_custom_exception_handler,
)
from reports.models import CommitReport, ReportResults
from rollouts import NO_PREPROCESS_UPLOAD
from services.task import TaskService
from upload.helpers import generate_upload_sentry_metrics_tags
from upload.serializers import CommitReportSerializer, ReportResultsSerializer
Expand Down Expand Up @@ -58,15 +57,15 @@ def perform_create(self, serializer):
code = serializer.validated_data.get("code")
if code == "default":
serializer.validated_data["code"] = None
instance = serializer.save(
instance, was_created = serializer.save(
commit_id=commit.id,
report_type=CommitReport.ReportType.COVERAGE,
)

if NO_PREPROCESS_UPLOAD.check_value(identifier=repository.repoid, default=True):
if was_created:
TaskService().preprocess_upload(
repository.repoid, commit.commitid, instance.code
)

sentry_metrics.incr(
"upload",
tags=generate_upload_sentry_metrics_tags(
Expand Down

0 comments on commit f6ed141

Please sign in to comment.