Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: debug daily statistic failed reason #2210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/concerns/attr_logics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def define_logic(attr_name, &block)

def reset(*attr_names)
attr_names.flatten.each do |a|
Rails.logger.info("RESET ATTR #{a} STARTED AT: #{Time.now}")
reset_one a
Rails.logger.info("RESET ATTR #{a} ENDED AT: #{Time.now}")
end
end

Expand Down
2 changes: 0 additions & 2 deletions app/models/daily_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/workers/charts/daily_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading