Skip to content

Commit 60c7fb5

Browse files
committed
address cal scheduler
1 parent 31c0362 commit 60c7fb5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/workers/calculate_address_info_worker.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ def perform()
1616
end
1717
Rails.cache.write(key, local_tip_block.id)
1818

19-
Address.where(id: contained_address_ids).find_in_batches do |group|
20-
sleep(50) # Make sure it doesn't get too crowded in there!
19+
Address.where(id: contained_address_ids).find_in_batches(batch_size: 100).with_index do |group, batch|
20+
puts "Processing group ##{batch}"
2121
address_attributes = []
2222

2323
group.each do |addr|
24+
# puts addr.id
2425
balance, balance_occupied = addr.cal_balance
2526
address_attributes << {
2627
id: addr.id,

lib/scheduler.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ def call_worker(clz)
115115
call_worker ContractStatisticWorker
116116
end
117117

118+
s.every "10h" overlap: false do
119+
call_worker CalculateAddressInfoWorker
120+
end
121+
118122
s.cron "0,30 * * * *" do
119123
BitcoinStatistic.refresh
120124
end

0 commit comments

Comments
 (0)