Skip to content

Commit

Permalink
Merge pull request #309 from kodadot/main
Browse files Browse the repository at this point in the history
🔖  Speck v14
  • Loading branch information
vikiival authored Sep 20, 2024
2 parents a14903c + 5c7c313 commit ecb9548
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/server-extension/model/tokenEntity.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Collection {

@Field(() => String, { nullable: true })
name!: string;

@Field(() => String, { nullable: true })
kind?: string;
}


Expand Down Expand Up @@ -100,6 +103,8 @@ export class TokenEntityModel {
@Field(() => Collection)
collection!: Collection;

@Field(() => String, { nullable: true })
kind?: string;

constructor(props: Partial<TokenEntityModel>) {
Object.assign(this, props);
Expand Down Expand Up @@ -150,6 +155,8 @@ export class TokenEntityQueryResult {
@Field(() => String, { nullable: false })
collection_name!: string;

@Field(() => String, { nullable: true })
kind?: string;

@Field(() => String, { nullable: false })
meta_id!: string;
Expand Down
2 changes: 2 additions & 0 deletions src/server-extension/query/tokenEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ SELECT
nc.supply as supply,
col.id AS collection_id,
col.name AS collection_name
col.kind AS kind
FROM
token_entity as t
JOIN collection_entity as col ON t.collection_id = col.id
Expand All @@ -64,4 +65,5 @@ WHERE
nc.supply > 0 AND
t.deleted = false AND
($10::text IS NULL OR LOWER(t.name) LIKE LOWER('%' || $10 || '%'))
AND ($11::text IS NULL OR col.kind = $11)
`
8 changes: 6 additions & 2 deletions src/server-extension/resolvers/tokenEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class TokenResolver {
@Arg('price_lte', { nullable: true }) price_lte?: number,
@Arg('denyList', () => [String], { nullable: true }) denyList?: string[],
@Arg('collections', () => [String], { nullable: true }) collections?: string[],
@Arg('name', { nullable: true }) name?: string
@Arg('name', { nullable: true }) name?: string,
@Arg('kind', { nullable: true }) kind?: string
): Promise<TokenEntityModel[]> {
const orderQuery = this.getOrderByQuery(orderBy)

Expand All @@ -40,7 +41,8 @@ ORDER BY ${orderQuery} LIMIT $2 OFFSET $3;
denyList,
issuer,
collections,
name
name,
kind
])
return result.map(this.mapRowToTokenEntityByOwner)
}
Expand All @@ -51,6 +53,7 @@ ORDER BY ${orderQuery} LIMIT $2 OFFSET $3;
blockNumber: row.block_number,
createdAt: row.created_at,
updatedAt: row.updated_at,
kind: row.kind,
cheapest: {
id: row.cheapest_id,
price: row.cheapest_price,
Expand All @@ -59,6 +62,7 @@ ORDER BY ${orderQuery} LIMIT $2 OFFSET $3;
collection: {
id: row.collection_id,
name: row.collection_name,
kind: row.kind,
},
meta: {
id: row.meta_id,
Expand Down

0 comments on commit ecb9548

Please sign in to comment.