Skip to content

Commit

Permalink
benchmark validationjob
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Feb 14, 2020
1 parent d062b8e commit fa3c07c
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions app/jobs/validation_job.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
require 'benchmark'

class ValidationJob < ActiveJob::Base
queue_as :sashimi

def perform(id, options={})
subset = ReportSubset.where(id: id).first
full_report = ActiveSupport::Gzip.decompress(subset.compressed)
parsed = JSON.parse(full_report)
subset = nil
full_report = nil
subset = nil
header = nil
parsed = nil
is_valid = nil

bm = Benchmark.ms {
subset = ReportSubset.where(id: id).first
full_report = ActiveSupport::Gzip.decompress(subset.compressed)
}
Rails.logger.warn message: "[ValidationJob] Decompress", duration: bm

bm = Benchmark.ms {
parsed = JSON.parse(full_report)
}
Rails.logger.warn message: "[ValidationJob] Parse", duration: bm

header = parsed.dig("report-header")
header["report-datasets"] = parsed.dig("report-datasets")

# validate subset of usage report, raise error with bug tracker otherwise
is_valid = subset.validate_this_sushi_with_error(header)
bm = Benchmark.ms {
# validate subset of usage report, raise error with bug tracker otherwise
is_valid = subset.validate_this_sushi_with_error(header)
}
Rails.logger.warn message: "[ValidationJob] Validation", duration: bm

if is_valid
message = "[ValidationJob] Subset #{id} of Usage Report #{subset.report.uid} successfully validated."
Expand Down

0 comments on commit fa3c07c

Please sign in to comment.