Skip to content

Commit

Permalink
bring back regular UNION && remove joining on fungible tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
kstepanovdev committed Jan 15, 2025
1 parent 6838e89 commit 16585a0
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions postgre-client/src/asset_filter_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl PgClient {
| TokenType::RegularNFT
| TokenType::CompressedNFT => {}
TokenType::All => {
query_builder.push(" UNION ALL ");
query_builder.push(" UNION ");
query_builder.push(" ( ");
query_builder.push(
"SELECT
Expand Down Expand Up @@ -203,20 +203,6 @@ fn add_filter_clause<'a>(
query_builder.push(" INNER JOIN assets_authorities ON assets_v3.ast_authority_fk = assets_authorities.auth_pubkey ");
group_clause_required = true;
}
if let Some(ref token_type) = filter.token_type {
if token_type == &TokenType::All && filter.owner_address.is_some() {
query_builder.push(
" LEFT JOIN fungible_tokens ON assets_v3.ast_pubkey = fungible_tokens.fbt_asset ",
);
group_clause_required = true;
}
if token_type == &TokenType::Fungible && filter.owner_address.is_some() {
query_builder.push(
" INNER JOIN fungible_tokens ON assets_v3.ast_pubkey = fungible_tokens.fbt_asset ",
);
group_clause_required = true;
}
}

// todo: if we implement the additional params like negata and all/any switch, the true part and the AND prefix should be refactored
query_builder.push(" WHERE TRUE ");
Expand Down Expand Up @@ -296,10 +282,6 @@ fn add_filter_clause<'a>(
TokenType::All => {
query_builder.push(" AND (assets_v3.ast_owner = ");
query_builder.push_bind(owner_address);
if !options.show_zero_balance {
query_builder.push(" AND fungible_tokens.fbt_balance > ");
query_builder.push_bind(0i64);
}
query_builder.push(")");
}
}
Expand Down

0 comments on commit 16585a0

Please sign in to comment.