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

Commit d0fb6ee

Browse files
committed
Stop writing UploadLevelTotals
I believe these are completely unused. They were still being created/updated though.
1 parent 66ca059 commit d0fb6ee

File tree

3 files changed

+1
-162
lines changed

3 files changed

+1
-162
lines changed

database/tests/factories/core.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,6 @@ class Meta:
233233
created_at = datetime.now()
234234

235235

236-
class UploadLevelTotalsFactory(Factory):
237-
class Meta:
238-
model = models.UploadLevelTotals
239-
240-
upload = factory.SubFactory(UploadFactory)
241-
branches = 0
242-
coverage = 0.00
243-
hits = 0
244-
lines = 0
245-
methods = 0
246-
misses = 0
247-
partials = 0
248-
files = 0
249-
250-
251236
class RepositoryFlagFactory(Factory):
252237
class Meta:
253238
model = models.RepositoryFlag

services/report/__init__.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
ReportDetails,
3535
ReportLevelTotals,
3636
RepositoryFlag,
37-
UploadLevelTotals,
3837
)
3938
from helpers.environment import Environment, get_current_env
4039
from helpers.exceptions import (
@@ -1076,12 +1075,6 @@ def build_report_from_raw_content(
10761075
def update_upload_with_processing_result(
10771076
self, upload_obj: Upload, processing_result: ProcessingResult
10781077
):
1079-
rounding: str = read_yaml_field(
1080-
self.current_yaml, ("coverage", "round"), "nearest"
1081-
)
1082-
precision: int = read_yaml_field(
1083-
self.current_yaml, ("coverage", "precision"), 2
1084-
)
10851078
db_session = upload_obj.get_db_session()
10861079
session = processing_result.session
10871080
if processing_result.error is None:
@@ -1095,24 +1088,6 @@ def update_upload_with_processing_result(
10951088
upload_obj.state_id = UploadState.PROCESSED.db_id
10961089
upload_obj.state = "processed"
10971090
upload_obj.order_number = session.id
1098-
upload_totals = upload_obj.totals
1099-
if upload_totals is None:
1100-
upload_totals = UploadLevelTotals(
1101-
upload_id=upload_obj.id,
1102-
branches=0,
1103-
coverage=0,
1104-
hits=0,
1105-
lines=0,
1106-
methods=0,
1107-
misses=0,
1108-
partials=0,
1109-
files=0,
1110-
)
1111-
db_session.add(upload_totals)
1112-
if session.totals is not None:
1113-
upload_totals.update_from_totals(
1114-
session.totals, precision=precision, rounding=rounding
1115-
)
11161091
else:
11171092
error = processing_result.error
11181093
upload_obj.state = "error"
@@ -1123,7 +1098,7 @@ def update_upload_with_processing_result(
11231098
error_params=error.params,
11241099
)
11251100
db_session.add(error_obj)
1126-
db_session.flush()
1101+
db_session.flush()
11271102

11281103
@sentry_sdk.trace
11291104
def save_report(self, commit: Commit, report: Report, report_code=None):
@@ -1252,12 +1227,6 @@ def save_full_report(
12521227
db_session.add(upload)
12531228
db_session.flush()
12541229
self._attach_flags_to_upload(upload, session.flags if session.flags else [])
1255-
if session.totals is not None:
1256-
upload_totals = UploadLevelTotals(upload_id=upload.id_)
1257-
db_session.add(upload_totals)
1258-
upload_totals.update_from_totals(
1259-
session.totals, precision=precision, rounding=rounding
1260-
)
12611230
return res
12621231

12631232
@sentry_sdk.trace

services/tests/test_report.py

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
ReportLevelTotalsFactory,
1919
RepositoryFlagFactory,
2020
UploadFactory,
21-
UploadLevelTotalsFactory,
2221
)
2322
from helpers.exceptions import RepositoryWithoutValidBotError
2423
from services.archive import ArchiveService
@@ -477,18 +476,6 @@ def test_build_report_from_commit(self, dbsession, mock_storage):
477476

478477
upload = UploadFactory(report=report, order_number=0, upload_type="upload")
479478
dbsession.add(upload)
480-
upload_totals = UploadLevelTotalsFactory(
481-
upload=upload,
482-
files=3,
483-
lines=20,
484-
hits=17,
485-
misses=3,
486-
partials=0,
487-
coverage=85.0,
488-
branches=0,
489-
methods=0,
490-
)
491-
dbsession.add(upload_totals)
492479
dbsession.commit()
493480
dbsession.flush()
494481

@@ -524,21 +511,6 @@ def test_build_report_from_commit(self, dbsession, mock_storage):
524511
assert len(report.sessions) == 1
525512
assert report.sessions[0].flags == []
526513
assert report.sessions[0].session_type == SessionType.uploaded
527-
assert report.sessions[0].totals == ReportTotals(
528-
files=3,
529-
lines=20,
530-
hits=17,
531-
misses=3,
532-
partials=0,
533-
coverage=Decimal("85.00"),
534-
branches=0,
535-
methods=0,
536-
messages=0,
537-
sessions=0,
538-
complexity=0,
539-
complexity_total=0,
540-
diff=0,
541-
)
542514

543515
# make sure report is still serializable
544516
ReportService({}).save_report(commit, report)
@@ -606,73 +578,25 @@ def test_build_report_from_commit_with_flags(self, dbsession, mock_storage):
606578
report=report, flags=[flag1], order_number=0, upload_type="upload"
607579
)
608580
dbsession.add(upload1)
609-
upload_totals1 = UploadLevelTotalsFactory(
610-
upload=upload1,
611-
files=3,
612-
lines=20,
613-
hits=17,
614-
misses=3,
615-
partials=0,
616-
coverage=85.0,
617-
branches=0,
618-
methods=0,
619-
)
620-
dbsession.add(upload_totals1)
621581
dbsession.commit()
622582

623583
upload2 = UploadFactory(
624584
report=report, flags=[flag1], order_number=1, upload_type="carriedforward"
625585
)
626586
dbsession.add(upload2)
627-
upload_totals2 = UploadLevelTotalsFactory(
628-
upload=upload2,
629-
files=3,
630-
lines=20,
631-
hits=20,
632-
misses=0,
633-
partials=0,
634-
coverage=100.0,
635-
branches=0,
636-
methods=0,
637-
)
638-
dbsession.add(upload_totals2)
639587
dbsession.commit()
640588

641589
upload3 = UploadFactory(
642590
report=report, flags=[flag2], order_number=2, upload_type="carriedforward"
643591
)
644592
dbsession.add(upload3)
645-
upload_totals3 = UploadLevelTotalsFactory(
646-
upload=upload3,
647-
files=3,
648-
lines=20,
649-
hits=20,
650-
misses=0,
651-
partials=0,
652-
coverage=100.0,
653-
branches=0,
654-
methods=0,
655-
)
656-
dbsession.add(upload_totals3)
657593
dbsession.commit()
658594
dbsession.flush()
659595

660596
upload4 = UploadFactory(
661597
report=report, flags=[flag3], order_number=3, upload_type="upload"
662598
)
663599
dbsession.add(upload4)
664-
upload_totals4 = UploadLevelTotalsFactory(
665-
upload=upload4,
666-
files=3,
667-
lines=20,
668-
hits=20,
669-
misses=0,
670-
partials=0,
671-
coverage=100.0,
672-
branches=0,
673-
methods=0,
674-
)
675-
dbsession.add(upload_totals4)
676600
dbsession.commit()
677601
dbsession.flush()
678602

@@ -719,39 +643,9 @@ def test_build_report_from_commit_with_flags(self, dbsession, mock_storage):
719643
assert len(report.sessions) == 2
720644
assert report.sessions[0].flags == ["unit"]
721645
assert report.sessions[0].session_type == SessionType.uploaded
722-
assert report.sessions[0].totals == ReportTotals(
723-
files=3,
724-
lines=20,
725-
hits=17,
726-
misses=3,
727-
partials=0,
728-
coverage=Decimal("85.00"),
729-
branches=0,
730-
methods=0,
731-
messages=0,
732-
sessions=0,
733-
complexity=0,
734-
complexity_total=0,
735-
diff=0,
736-
)
737646
assert 1 not in report.sessions # CF w/ equivalent direct upload
738647
assert report.sessions[2].flags == ["integration"]
739648
assert report.sessions[2].session_type == SessionType.carriedforward
740-
assert report.sessions[2].totals == ReportTotals(
741-
files=3,
742-
lines=20,
743-
hits=20,
744-
misses=0,
745-
partials=0,
746-
coverage=Decimal("100.00"),
747-
branches=0,
748-
methods=0,
749-
messages=0,
750-
sessions=0,
751-
complexity=0,
752-
complexity_total=0,
753-
diff=0,
754-
)
755649
assert 3 not in report.sessions # labels flag w/ empty label set
756650

757651
# make sure report is still serializable
@@ -3576,15 +3470,6 @@ def test_save_full_report(
35763470
assert len(first_upload.flags) == 1
35773471
assert first_upload.flags[0].repository == commit.repository
35783472
assert first_upload.flags[0].flag_name == "unit"
3579-
assert first_upload.totals is not None
3580-
assert first_upload.totals.branches == 0
3581-
assert first_upload.totals.coverage == Decimal("0.0")
3582-
assert first_upload.totals.hits == 0
3583-
assert first_upload.totals.lines == 10
3584-
assert first_upload.totals.methods == 0
3585-
assert first_upload.totals.misses == 0
3586-
assert first_upload.totals.partials == 0
3587-
assert first_upload.totals.files == 2
35883473
assert first_upload.upload_extras == {}
35893474
assert first_upload.upload_type == "uploaded"
35903475
assert second_upload.build_code == "poli"

0 commit comments

Comments
 (0)