From 5aac8cefd2e0391b8b93c05d2fb3abdd913b50bb Mon Sep 17 00:00:00 2001 From: Rabbit Date: Tue, 12 Nov 2024 13:35:54 +0800 Subject: [PATCH 1/2] chore: update dalli client TTL conf --- config/environments/production.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 340573921..7510b3b38 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -103,8 +103,7 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - client = Dalli::Client.new(ENV["MEMCACHED_URL"], - value_max_bytes: 10485760) + client = Dalli::Client.new(ENV["MEMCACHED_URL"], value_max_bytes: 10485760, expires_in: 86400) config.action_dispatch.rack_cache = { verbose: true, metastore: client, From 2f48b998db9391ae4effdc1fc0395ab733481c22 Mon Sep 17 00:00:00 2001 From: Rabbit Date: Fri, 15 Nov 2024 13:51:23 +0800 Subject: [PATCH 2/2] chore: add holder field to udt serialization --- app/models/udt.rb | 4 ++++ app/serializers/udt_serializer.rb | 5 ++++- .../controllers/api/v1/omiga_inscriptions_controller_test.rb | 4 ++-- test/controllers/api/v1/udts_controller_test.rb | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/udt.rb b/app/models/udt.rb index 5f10557e0..136a932e6 100644 --- a/app/models/udt.rb +++ b/app/models/udt.rb @@ -42,6 +42,10 @@ def type_script hash_type:, } end + + def holders_count + udt_holder_allocations.sum("ckb_holder_count + btc_holder_count") + end end # == Schema Information diff --git a/app/serializers/udt_serializer.rb b/app/serializers/udt_serializer.rb index 49ee340d0..3730e68a4 100644 --- a/app/serializers/udt_serializer.rb +++ b/app/serializers/udt_serializer.rb @@ -22,9 +22,12 @@ class UdtSerializer attribute :h24_ckb_transactions_count do |object| object.h24_ckb_transactions_count.to_s end - attributes :created_at do |object| + attribute :created_at do |object| object.block_timestamp.to_s end + attribute :holder do |object| + object.holders_count.to_s + end attribute :mint_status, if: Proc.new { |record, _params| record.udt_type == "omiga_inscription" diff --git a/test/controllers/api/v1/omiga_inscriptions_controller_test.rb b/test/controllers/api/v1/omiga_inscriptions_controller_test.rb index dde4b207e..faf015653 100644 --- a/test/controllers/api/v1/omiga_inscriptions_controller_test.rb +++ b/test/controllers/api/v1/omiga_inscriptions_controller_test.rb @@ -72,7 +72,7 @@ class OmigaInscriptionsControllerTest < ActionDispatch::IntegrationTest assert_equal %w( symbol full_name total_amount addresses_count decimal icon_file h24_ckb_transactions_count created_at description - published type_hash type_script issuer_address mint_status mint_limit expected_supply + published type_hash type_script issuer_address mint_status mint_limit expected_supply holder inscription_info_id udt_type pre_udt_hash info_type_hash operator_website email is_repeated_symbol ).sort, response_udt["attributes"].keys.sort @@ -86,7 +86,7 @@ class OmigaInscriptionsControllerTest < ActionDispatch::IntegrationTest response_udt = json["data"] assert_equal %w( symbol full_name total_amount addresses_count - decimal icon_file h24_ckb_transactions_count created_at description + decimal icon_file h24_ckb_transactions_count created_at description holder published type_hash type_script issuer_address mint_status mint_limit expected_supply inscription_info_id udt_type pre_udt_hash info_type_hash operator_website email is_repeated_symbol ).sort, diff --git a/test/controllers/api/v1/udts_controller_test.rb b/test/controllers/api/v1/udts_controller_test.rb index bd742fa68..c294a9802 100644 --- a/test/controllers/api/v1/udts_controller_test.rb +++ b/test/controllers/api/v1/udts_controller_test.rb @@ -120,7 +120,7 @@ class UdtsControllerTest < ActionDispatch::IntegrationTest response_tx_transaction = json["data"] assert_equal %w( - symbol full_name total_amount addresses_count + symbol full_name total_amount addresses_count holder decimal icon_file h24_ckb_transactions_count created_at description published type_hash type_script issuer_address udt_type operator_website email ).sort,