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

Deploy to testnet #1465

Merged
merged 3 commits into from
Oct 11, 2023
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
8 changes: 4 additions & 4 deletions app/controllers/api/v1/address_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class AddressTransactionsController < ApplicationController
before_action :set_address_transactions, only: [:show, :download_csv]

def show
@tx_ids = AccountBook.
joins(:ckb_transaction).
where(address_id: @address.id)
@tx_ids = AccountBook.joins(:ckb_transaction).
where(account_books: { address_id: @address.id },
ckb_transactions: { tx_status: "committed" })

params[:sort] ||= "ckb_transaction_id.desc"
order_by, asc_or_desc = params[:sort].split(".", 2)
Expand All @@ -29,7 +29,7 @@ def show
page(@page).per(@page_size).fast_page

order_by = "id" if order_by == "ckb_transaction_id"
@ckb_transactions = CkbTransaction.tx_committed.where(id: @tx_ids.map(&:ckb_transaction_id)).
@ckb_transactions = CkbTransaction.where(id: @tx_ids.map(&:ckb_transaction_id)).
select(:id, :tx_hash, :block_id, :block_number, :block_timestamp, :is_cellbase, :updated_at, :capacity_involved).
order(order_by => asc_or_desc)

Expand Down
14 changes: 8 additions & 6 deletions app/controllers/api/v2/ckb_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def build_cell_capacities(outputs)
udt_info = parsed_output.udt_info

if (cell_capacity = cell_capacities[[address, unit]]).blank?
capacity = unit == "CKB" ? parsed_output.capacity.to_f : 0.0
cell_capacity = {
capacity: capacity,
capacity: parsed_output.capacity.to_f,
cell_type: parsed_output.cell_type,
udt_info: {
symbol: udt_info&.symbol,
Expand All @@ -40,12 +39,12 @@ def build_cell_capacities(outputs)
published: !!udt_info&.published,
display_name: udt_info&.display_name,
uan: udt_info&.uan
}
},
m_nft_info: parsed_output.m_nft_info.to_h
}
elsif unit == "CKB"
cell_capacity[:capacity] += parsed_output.capacity.to_f
else
cell_capacity[:udt_info][:amount] += udt_info.amount.to_f
cell_capacity[:capacity] += parsed_output.capacity.to_f
cell_capacity[:udt_info][:amount] += udt_info.amount.to_f unless unit == "CKB"
end

cell_capacities[[address, unit]] = cell_capacity
Expand All @@ -65,8 +64,11 @@ def build_transfers(input_capacities, output_capacities)
# There may be keys in both input_capacities and output_capacities that do not exist
cell_type = output[:cell_type] || input[:cell_type]
capacity_change = output[:capacity].to_f - input[:capacity].to_f
m_nft_info = output[:m_nft_info] || input[:m_nft_info]

transfer = { capacity: capacity_change, cell_type: cell_type }
transfer[:m_nft_info] = m_nft_info if m_nft_info.present?

if unit != "CKB"
output_amount = output[:udt_info] ? output[:udt_info][:amount] : 0.0
input_amount = input[:udt_info] ? input[:udt_info][:amount] : 0.0
Expand Down
2 changes: 1 addition & 1 deletion lib/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def call_worker(clz)
ApplicationRecord.connection.execute "vacuum (verbose, analyze)"
end

s.cron "5 0 * * *" do
s.cron "0 8 * * *" do
call_worker Charts::DailyStatistic
end

Expand Down
Loading