Skip to content

Commit

Permalink
Merge pull request #120 from kodadot/main
Browse files Browse the repository at this point in the history
🔖  Speck v5.1.1
  • Loading branch information
vikiival authored Oct 17, 2023
2 parents 74a6d67 + 6673e66 commit 2ba8586
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/server-extension/query/tokenEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ filters_applied AS (
($7::text[] IS NULL OR ne.issuer NOT IN (SELECT unnest($7))) AND
($4::bigint IS NULL OR ne.price >= $4::bigint) AND
($5::bigint IS NULL OR ne.price > $5::bigint) AND
($6::bigint IS NULL OR ne.price <= $6::bigint)
($6::bigint IS NULL OR ne.price <= $6::bigint) AND
($9::text[] IS NULL OR ne.collection_id = ANY($9))
),
nft_count AS (
SELECT
Expand Down
7 changes: 4 additions & 3 deletions src/server-extension/query/totalTokenEntities.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export const totalTokenEntities = `
SELECT COUNT(id) as total_count
SELECT COUNT(DISTINCT token_id) as total_count
FROM nft_entity
WHERE
($1::text IS NULL OR current_owner = $1) AND
($6::text IS NULL OR issuer = $6) AND
($5::text[] IS NULL OR issuer NOT IN (SELECT unnest($5))) AND
($2::bigint IS NULL OR price >= $2::bigint) AND
($3::bigint IS NULL OR price > $3::bigint) AND
($4::bigint IS NULL OR price <= $4::bigint);
`
($4::bigint IS NULL OR price <= $4::bigint) AND
($7::text[] IS NULL OR nft_entity.collection_id = ANY($7));
`
4 changes: 3 additions & 1 deletion src/server-extension/resolvers/tokenEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class TokenResolver {
@Arg('price_gte', { nullable: true }) price_gte?: number,
@Arg('price_gt', { nullable: true }) price_gt?: number,
@Arg('price_lte', { nullable: true }) price_lte?: number,
@Arg('denyList', () => [String], { nullable: true }) denyList?: string[]
@Arg('denyList', () => [String], { nullable: true }) denyList?: string[],
@Arg('collections', () => [String], { nullable: true }) collections?: string[]
): Promise<TokenEntityModel[]> {
const orderQuery = this.getOrderByQuery(orderBy)

Expand All @@ -37,6 +38,7 @@ ORDER BY ${orderQuery} LIMIT $2 OFFSET $3;
price_lte,
denyList,
issuer,
collections,
])
return result.map(this.mapRowToTokenEntityByOwner)
}
Expand Down
4 changes: 3 additions & 1 deletion src/server-extension/resolvers/totalTokenEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export class TokenCountResolver {
@Arg('price_gte', { nullable: true }) price_gte?: number,
@Arg('price_gt', { nullable: true }) price_gt?: number,
@Arg('price_lte', { nullable: true }) price_lte?: number,
@Arg('denyList', () => [String], { nullable: true }) denyList?: string[]
@Arg('denyList', () => [String], { nullable: true }) denyList?: string[],
@Arg('collections', () => [String], { nullable: true }) collections?: string[]
): Promise<CountEntity> {
const rawData: CountEntityQueryResult[] = await makeQuery(this.tx, CountEntity, totalTokenEntities, [
owner,
Expand All @@ -25,6 +26,7 @@ export class TokenCountResolver {
price_lte,
denyList,
issuer,
collections,
])
return new CountEntity(rawData[0].total_count)
}
Expand Down

0 comments on commit 2ba8586

Please sign in to comment.