@@ -2177,9 +2177,15 @@ def find_or_create_report(opts)
2177
2177
# @return [Integer] ID of created report
2178
2178
def report_report ( opts )
2179
2179
return if not active
2180
- ::ActiveRecord ::Base . connection_pool . with_connection {
2180
+ created = opts . delete ( :created_at )
2181
+ updated = opts . delete ( :updated_at )
2182
+ state = opts . delete ( :state )
2181
2183
2184
+ ::ActiveRecord ::Base . connection_pool . with_connection {
2182
2185
report = Report . new ( opts )
2186
+ report . created_at = created
2187
+ report . updated_at = updated
2188
+
2183
2189
unless report . valid?
2184
2190
errors = report . errors . full_messages . join ( '; ' )
2185
2191
raise RuntimeError "Report to be imported is not valid: #{ errors } "
@@ -2194,10 +2200,14 @@ def report_report(opts)
2194
2200
# Creates a ReportArtifact based on passed parameters.
2195
2201
# @param opts [Hash] of ReportArtifact attributes
2196
2202
def report_artifact ( opts )
2203
+ return if not active
2204
+
2197
2205
artifacts_dir = Report ::ARTIFACT_DIR
2198
2206
tmp_path = opts [ :file_path ]
2199
2207
artifact_name = File . basename tmp_path
2200
2208
new_path = File . join ( artifacts_dir , artifact_name )
2209
+ created = opts . delete ( :created_at )
2210
+ updated = opts . delete ( :updated_at )
2201
2211
2202
2212
unless File . exists? tmp_path
2203
2213
raise DBImportError 'Report artifact file to be imported does not exist.'
@@ -2215,6 +2225,9 @@ def report_artifact(opts)
2215
2225
FileUtils . copy ( tmp_path , new_path )
2216
2226
opts [ :file_path ] = new_path
2217
2227
artifact = ReportArtifact . new ( opts )
2228
+ artifact . created_at = created
2229
+ artifact . updated_at = updated
2230
+
2218
2231
unless artifact . valid?
2219
2232
errors = artifact . errors . full_messages . join ( '; ' )
2220
2233
raise RuntimeError "Artifact to be imported is not valid: #{ errors } "
0 commit comments