Skip to content

Commit

Permalink
move COLLECTION_GROUP_KEY to const
Browse files Browse the repository at this point in the history
  • Loading branch information
RequescoS committed Jan 4, 2024
1 parent fbdb6da commit d16069a
Showing 1 changed file with 4 additions and 42 deletions.
46 changes: 4 additions & 42 deletions digital_asset_types/src/dao/scopes/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -102,7 +103,7 @@ pub async fn get_grouping(
group_key: String,
group_value: String,
) -> Result<GroupingSize, DbErr> {
if group_value != *"collection" {
if group_value != COLLECTION_GROUP_KEY {
return Ok(GroupingSize { size: 0 });
}

Expand Down Expand Up @@ -141,7 +142,7 @@ pub async fn get_by_grouping(
pagination: &Pagination,
limit: u64,
) -> Result<Vec<FullAsset>, DbErr> {
if group_key != *"collection" {
if group_key != COLLECTION_GROUP_KEY {
return Ok(vec![]);
}

Expand Down Expand Up @@ -295,45 +296,6 @@ pub async fn get_related_for_assets(
Ok(assets)
}

#[derive(FromQueryResult, Debug, Clone, PartialEq)]
struct AssetWithMetadata {
ast_pubkey: Vec<u8>,
ast_delegate: Option<Vec<u8>>,
ast_owner: Option<Vec<u8>>,
ast_authority: Option<Vec<u8>>,
ast_collection: Option<Vec<u8>>,
ast_is_collection_verified: bool,
ast_collection_seq: Option<i64>,
ast_is_compressed: bool,
ast_is_compressible: bool,
ast_is_frozen: bool,
ast_supply: Option<i64>,
ast_seq: Option<i64>,
ast_tree_id: Option<Vec<u8>>,
ast_leaf: Option<Vec<u8>>,
ast_nonce: Option<i64>,
ast_royalty_target_type: RoyaltyTargetType,
ast_royalty_target: Option<Vec<u8>>,
ast_royalty_amount: i64,
ast_created_at: i64,
ast_is_burnt: bool,
ast_slot_updated: Option<i64>,
ast_data_hash: Option<String>,
ast_creator_hash: Option<String>,
ast_owner_delegate_seq: Option<i64>,
ast_was_decompressed: bool,
ast_leaf_seq: Option<i64>,
ast_specification_version: SpecificationVersions,
ast_specification_asset_class: Option<SpecificationAssetClass>,
ast_owner_type: OwnerType,
ast_onchain_data: Option<String>,
ofd_metadata_url: Option<String>,
ofd_metadata: Option<String>,
ofd_chain_data_mutability: Option<ChainMutability>,
}

impl AssetWithMetadata {}

fn convert_rocks_offchain_data(
asset_pubkey: &Pubkey,
offchain_data: &OffChainData,
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit d16069a

Please sign in to comment.