Skip to content

Commit

Permalink
feat: add block list serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Dec 25, 2019
1 parent 26e5a36 commit 8d729d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def index
options = FastJsonapi::PaginationMetaGenerator.new(request: request, records: blocks, page: @page, page_size: @page_size).call
end

render json: BlockSerializer.new(blocks, options)
render json: BlockListSerializer.new(blocks, options)
end

def show
Expand Down
18 changes: 18 additions & 0 deletions app/serializers/block_list_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class BlockListSerializer
include FastJsonapi::ObjectSerializer

attributes :miner_hash

attribute :number do |object|
object.number.to_s
end
attribute :timestamp do |object|
object.timestamp.to_s
end
attribute :reward do |object|
object.reward.to_s
end
attribute :transactions_count do |object|
object.ckb_transactions_count.to_s
end
end

0 comments on commit 8d729d7

Please sign in to comment.