From cd72034b528b4cfbb08f447a2c098b3b8957d1b4 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Tue, 5 Mar 2024 14:58:49 +0800 Subject: [PATCH] fix: update task to refresh items_count value (#1667) * fix: update task to refresh items_count value Signed-off-by: Miles Zhang * test: fix daily statistic generator test Signed-off-by: Miles Zhang --------- Signed-off-by: Miles Zhang --- .../update_holders_and_items_count_on_collections.rake | 3 +-- test/services/charts/daily_statistic_generator_test.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/tasks/migration/update_holders_and_items_count_on_collections.rake b/lib/tasks/migration/update_holders_and_items_count_on_collections.rake index 437546ed4..64e75e142 100644 --- a/lib/tasks/migration/update_holders_and_items_count_on_collections.rake +++ b/lib/tasks/migration/update_holders_and_items_count_on_collections.rake @@ -6,9 +6,8 @@ namespace :migration do TokenCollection.find_each do |collection| items_count = collection.items.normal.count - TokenCollection.update_counters(collection.id, items_count:) holders_count = collection.items.normal.distinct.count(:owner_id) - collection.update_column(:holders_count, holders_count) + collection.update(holders_count:, items_count:) progress_bar.increment end end diff --git a/test/services/charts/daily_statistic_generator_test.rb b/test/services/charts/daily_statistic_generator_test.rb index 38342c773..9b42f780b 100644 --- a/test/services/charts/daily_statistic_generator_test.rb +++ b/test/services/charts/daily_statistic_generator_test.rb @@ -236,7 +236,7 @@ class DailyStatisticGeneratorTest < ActiveSupport::TestCase create(:cell_output, :with_full_transaction, block_timestamp: @datetime.to_i * 1000, block: @block), ] - CellOutput.where(id: cells.map(&:id)).update_all(consumed_block_timestamp: (@datetime.to_i + 10) * 1000) + CellOutput.where(id: cells.map(&:id)).update_all(consumed_block_timestamp: (@datetime.to_i + 1) * 1000) is_from_scratch = true assert_equal "3", Charts::DailyStatisticGenerator.new(@datetime,