Skip to content

Commit

Permalink
Stop writing ReportDetails/files_array (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem authored Nov 4, 2024
1 parent 25b28c4 commit 8fec23c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 443 deletions.
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem
https://github.com/codecov/shared/archive/cde98920fbec05ad7f71f934fed35a5eebab4dd3.tar.gz#egg=shared
https://github.com/codecov/shared/archive/6e68957eb90e234cbec237ede814e1d36b170291.tar.gz#egg=shared
https://github.com/codecov/test-results-parser/archive/ef39a0888acd62d02a316a852a15d755c74e78c6.tar.gz#egg=test-results-parser
https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring
asgiref>=3.7.2
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ sentry-sdk[celery]==2.13.0
# via
# -r requirements.in
# shared
shared @ https://github.com/codecov/shared/archive/cde98920fbec05ad7f71f934fed35a5eebab4dd3.tar.gz
shared @ https://github.com/codecov/shared/archive/6e68957eb90e234cbec237ede814e1d36b170291.tar.gz
# via -r requirements.in
six==1.16.0
# via
Expand Down
47 changes: 1 addition & 46 deletions services/report/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import itertools
import logging
import sys
import uuid
from dataclasses import dataclass
from time import time
Expand All @@ -27,7 +26,6 @@
from database.models import Commit, Repository, Upload, UploadError
from database.models.reports import (
CommitReport,
ReportDetails,
ReportLevelTotals,
RepositoryFlag,
UploadLevelTotals,
Expand Down Expand Up @@ -181,8 +179,7 @@ def initialize_and_save_report(
This is one of the main entrypoint of this class. It takes care of:
- Creating the most basic models relating to that commit
report (CommitReport and ReportDetails), if needed
- Creating the `CommitReport`, if needed
- If that commit is old-style (was created before the report models were installed),
it takes care of backfilling all the information from the report into the new
report models
Expand Down Expand Up @@ -215,19 +212,6 @@ def initialize_and_save_report(
)
db_session.add(current_report_row)
db_session.flush()
report_details = (
db_session.query(ReportDetails)
.filter_by(report_id=current_report_row.id_)
.first()
)
if report_details is None:
report_details = ReportDetails(
report_id=current_report_row.id_,
_files_array=[],
report=current_report_row,
)
db_session.add(report_details)
db_session.flush()

actual_report = self.get_existing_report_for_commit(
commit, report_code=report_code
Expand All @@ -241,15 +225,6 @@ def initialize_and_save_report(
# yet into the new models therefore it needs backfilling
self.save_full_report(commit, actual_report)

elif current_report_row.details is None:
report_details = ReportDetails(
report_id=current_report_row.id_,
_files_array=[],
report=current_report_row,
)
db_session.add(report_details)
db_session.flush()

if not self.has_initialized_report(commit):
report = self.create_new_report_for_commit(commit)
if not report.is_empty():
Expand Down Expand Up @@ -859,28 +834,8 @@ def save_report(self, commit: Commit, report: Report, report_code=None):

# `report` is an accessor which implicitly queries `CommitReport`
if commit_report := commit.report:
files_array = [
{
"filename": k,
"file_index": v.file_index,
"file_totals": v.file_totals,
"diff_totals": v.diff_totals,
}
for k, v in report._files.items()
]
log.info(
"Calling update to reports_reportdetails.files_array",
extra=dict(
size=sys.getsizeof(files_array),
ownerid=commit.repository.ownerid,
repoid=commit.repoid,
commitid=commit.commitid,
),
)
db_session = commit.get_db_session()

# `files_array` is an `ArchiveField`, so this will trigger an upload
commit_report.details.files_array = files_array
report_totals = commit_report.totals
if report_totals is None:
report_totals = ReportLevelTotals(report_id=commit_report.id)
Expand Down
Loading

0 comments on commit 8fec23c

Please sign in to comment.