11import copy
22import itertools
33import logging
4- import sys
54import uuid
65from dataclasses import dataclass
76from time import time
2726from database .models import Commit , Repository , Upload , UploadError
2827from database .models .reports import (
2928 CommitReport ,
30- ReportDetails ,
3129 ReportLevelTotals ,
3230 RepositoryFlag ,
3331 UploadLevelTotals ,
@@ -181,8 +179,7 @@ def initialize_and_save_report(
181179
182180
183181 This is one of the main entrypoint of this class. It takes care of:
184- - Creating the most basic models relating to that commit
185- report (CommitReport and ReportDetails), if needed
182+ - Creating the `CommitReport`, if needed
186183 - If that commit is old-style (was created before the report models were installed),
187184 it takes care of backfilling all the information from the report into the new
188185 report models
@@ -215,19 +212,6 @@ def initialize_and_save_report(
215212 )
216213 db_session .add (current_report_row )
217214 db_session .flush ()
218- report_details = (
219- db_session .query (ReportDetails )
220- .filter_by (report_id = current_report_row .id_ )
221- .first ()
222- )
223- if report_details is None :
224- report_details = ReportDetails (
225- report_id = current_report_row .id_ ,
226- _files_array = [],
227- report = current_report_row ,
228- )
229- db_session .add (report_details )
230- db_session .flush ()
231215
232216 actual_report = self .get_existing_report_for_commit (
233217 commit , report_code = report_code
@@ -241,15 +225,6 @@ def initialize_and_save_report(
241225 # yet into the new models therefore it needs backfilling
242226 self .save_full_report (commit , actual_report )
243227
244- elif current_report_row .details is None :
245- report_details = ReportDetails (
246- report_id = current_report_row .id_ ,
247- _files_array = [],
248- report = current_report_row ,
249- )
250- db_session .add (report_details )
251- db_session .flush ()
252-
253228 if not self .has_initialized_report (commit ):
254229 report = self .create_new_report_for_commit (commit )
255230 if not report .is_empty ():
@@ -859,28 +834,8 @@ def save_report(self, commit: Commit, report: Report, report_code=None):
859834
860835 # `report` is an accessor which implicitly queries `CommitReport`
861836 if commit_report := commit .report :
862- files_array = [
863- {
864- "filename" : k ,
865- "file_index" : v .file_index ,
866- "file_totals" : v .file_totals ,
867- "diff_totals" : v .diff_totals ,
868- }
869- for k , v in report ._files .items ()
870- ]
871- log .info (
872- "Calling update to reports_reportdetails.files_array" ,
873- extra = dict (
874- size = sys .getsizeof (files_array ),
875- ownerid = commit .repository .ownerid ,
876- repoid = commit .repoid ,
877- commitid = commit .commitid ,
878- ),
879- )
880837 db_session = commit .get_db_session ()
881838
882- # `files_array` is an `ArchiveField`, so this will trigger an upload
883- commit_report .details .files_array = files_array
884839 report_totals = commit_report .totals
885840 if report_totals is None :
886841 report_totals = ReportLevelTotals (report_id = commit_report .id )
0 commit comments