diff --git a/app/models/concerns/attr_logics.rb b/app/models/concerns/attr_logics.rb index 8c0022521..4b7a2dabd 100644 --- a/app/models/concerns/attr_logics.rb +++ b/app/models/concerns/attr_logics.rb @@ -20,7 +20,9 @@ def define_logic(attr_name, &block) def reset(*attr_names) attr_names.flatten.each do |a| + Logger.info("RESET ATTR #{a} STARTED AT: #{Time.now}") reset_one a + Logger.info("RESET ATTR #{a} ENDED AT: #{Time.now}") end end diff --git a/app/models/daily_statistic.rb b/app/models/daily_statistic.rb index e19c1b6c4..a94bc644c 100644 --- a/app/models/daily_statistic.rb +++ b/app/models/daily_statistic.rb @@ -399,13 +399,11 @@ def liquidity end define_logic :holder_count do - ActiveRecord::Base.connection.execute("SET statement_timeout = 0") live_query = CellOutput.live.generated_before(to_be_counted_date.to_i * 1000 - 1).select(:address_id).to_sql dead_query = CellOutput.dead.generated_before(to_be_counted_date.to_i * 1000 - 1).consumed_after(to_be_counted_date.to_i * 1000).select(:address_id).to_sql combined_query = "#{live_query} UNION #{dead_query}" count_query = "SELECT COUNT(DISTINCT address_id) AS count FROM (#{combined_query}) AS combined_results;" count = ActiveRecord::Base.connection.execute(count_query).first["count"] - ActiveRecord::Base.connection.execute("RESET statement_timeout") count end diff --git a/app/workers/charts/daily_statistic.rb b/app/workers/charts/daily_statistic.rb index ab84577ac..d6010e453 100644 --- a/app/workers/charts/daily_statistic.rb +++ b/app/workers/charts/daily_statistic.rb @@ -11,7 +11,9 @@ def perform(datetime = nil) start_time = Time.zone.at(last_record ? last_record.created_at_unixtimestamp : Block.find_by(number: 0).timestamp / 1000) while start_time < datetime start_time += 1.day + ActiveRecord::Base.connection.execute("SET statement_timeout = 0") Charts::DailyStatisticGenerator.new(start_time).call + ActiveRecord::Base.connection.execute("RESET statement_timeout") end end end