Skip to content

Commit

Permalink
remove corrupted recs and schedule task
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiningRay committed Nov 7, 2022
1 parent 3fed0a6 commit 822b82f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/models/token_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ def self.update_cell
tc.update_info
end
end

# removed the wrong token collections
def self.remove_corrupted
where(standard: 'nrc721').where(type_script_id: nil).or(where(creator_id: nil)).find_each do |tc|
tc.update_info rescue nil

if tc.cell.blank?
tc.destroy
end

unless CkbUtils.is_nrc_721_factory_cell?(tc.cell.data)
tc.destroy
end
end
end
end

# == Schema Information
Expand Down
8 changes: 8 additions & 0 deletions app/workers/clean_up_worker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# refresh materialized views periodically
class AverageBlockTimeGenerator
include Sidekiq::Worker

def perform
TokenCollection.remove_corrupted
end
end
4 changes: 4 additions & 0 deletions config/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ cal_address_unclaimed_compensation:
update_pool_txs_status:
cron: "*/5 * * * *"
class: "PoolTransactionCheckWorker"

clean_up_worker:
cron: "0 * * * *"
class: 'CleanUpWorker'

0 comments on commit 822b82f

Please sign in to comment.