Class: CopayNotifications::ParseNewStatementsJob
- Inherits:
-
Object
- Object
- CopayNotifications::ParseNewStatementsJob
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/copay_notifications/parse_new_statements_job.rb
Constant Summary collapse
- JOB_INTERVAL =
time (in seconds) between scheduling batch of jobs
Settings.mcp.notifications.job_interval
- BATCH_SIZE =
number of jobs to perform at next interval
Settings.mcp.notifications.batch_size
- STATSD_KEY_PREFIX =
'api.copay_notifications.json_file'
Instance Method Summary collapse
Instance Method Details
#perform(statements_json_byte) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/sidekiq/copay_notifications/parse_new_statements_job.rb', line 24 def perform(statements_json_byte) StatsD.increment("#{STATSD_KEY_PREFIX}.total") # Decode and parse large json file (~60-90k objects) statements_json = Oj.load(Base64.decode64(statements_json_byte)) unique_statements = statements_json.uniq { |statement| statement['veteranIdentifier'] } unique_statements.each_with_index do |statement, index| # For every BATCH_SIZE jobs, enqueue the next BATCH_SIZE amount of jobs JOB_INTERVAL seconds later CopayNotifications::NewStatementNotificationJob.perform_in( JOB_INTERVAL * (index / BATCH_SIZE), statement ) end end |