From d16069a24b7bb89f1933356d30bfaa1bdbee8a2d Mon Sep 17 00:00:00 2001 From: requesco Date: Thu, 4 Jan 2024 17:10:33 +0200 Subject: [PATCH] move COLLECTION_GROUP_KEY to const --- digital_asset_types/src/dao/scopes/asset.rs | 46 ++------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/digital_asset_types/src/dao/scopes/asset.rs b/digital_asset_types/src/dao/scopes/asset.rs index f4e6c7b42..a2e6ba352 100644 --- a/digital_asset_types/src/dao/scopes/asset.rs +++ b/digital_asset_types/src/dao/scopes/asset.rs @@ -25,6 +25,7 @@ use crate::dao::{ }; pub const PROCESSING_METADATA_STATE: &str = "processing"; +const COLLECTION_GROUP_KEY: &str = "collection"; pub fn paginate( pagination: &Pagination, @@ -102,7 +103,7 @@ pub async fn get_grouping( group_key: String, group_value: String, ) -> Result { - if group_value != *"collection" { + if group_value != COLLECTION_GROUP_KEY { return Ok(GroupingSize { size: 0 }); } @@ -141,7 +142,7 @@ pub async fn get_by_grouping( pagination: &Pagination, limit: u64, ) -> Result, DbErr> { - if group_key != *"collection" { + if group_key != COLLECTION_GROUP_KEY { return Ok(vec![]); } @@ -295,45 +296,6 @@ pub async fn get_related_for_assets( Ok(assets) } -#[derive(FromQueryResult, Debug, Clone, PartialEq)] -struct AssetWithMetadata { - ast_pubkey: Vec, - ast_delegate: Option>, - ast_owner: Option>, - ast_authority: Option>, - ast_collection: Option>, - ast_is_collection_verified: bool, - ast_collection_seq: Option, - ast_is_compressed: bool, - ast_is_compressible: bool, - ast_is_frozen: bool, - ast_supply: Option, - ast_seq: Option, - ast_tree_id: Option>, - ast_leaf: Option>, - ast_nonce: Option, - ast_royalty_target_type: RoyaltyTargetType, - ast_royalty_target: Option>, - ast_royalty_amount: i64, - ast_created_at: i64, - ast_is_burnt: bool, - ast_slot_updated: Option, - ast_data_hash: Option, - ast_creator_hash: Option, - ast_owner_delegate_seq: Option, - ast_was_decompressed: bool, - ast_leaf_seq: Option, - ast_specification_version: SpecificationVersions, - ast_specification_asset_class: Option, - ast_owner_type: OwnerType, - ast_onchain_data: Option, - ofd_metadata_url: Option, - ofd_metadata: Option, - ofd_chain_data_mutability: Option, -} - -impl AssetWithMetadata {} - fn convert_rocks_offchain_data( asset_pubkey: &Pubkey, offchain_data: &OffChainData, @@ -525,7 +487,7 @@ fn convert_rocks_grouping_model( asset_grouping::Model { id: 0, asset_id: asset_pubkey.to_bytes().to_vec(), - group_key: "collection".to_string(), + group_key: COLLECTION_GROUP_KEY.to_string(), group_value: collection.map(|asset| asset.collection.to_string()), seq: collection.map(|asset| asset.slot_updated as i64), slot_updated: collection.map(|asset| asset.slot_updated as i64),