Skip to content

Commit

Permalink
Allow search in top collection resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
justraman committed May 14, 2024
1 parent f8f0b4a commit f9517e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server-extension/resolvers/top_collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class TopCollectionResolver {
@Arg('timeFrame', () => Timeframe) timeFrame: Timeframe,
@Arg('orderBy', () => TopCollectionOrderBy) orderBy: TopCollectionOrderBy,
@Arg('category', () => [String], { nullable: true, defaultValue: [] }) category: string[],
@Arg('query', { nullable: true, description: 'Search by collection name' }) query: string,
@Arg('order', () => Order) order: Order,
@Arg('offset', () => Int) offset: number = 0,
@Arg('limit', () => Int) limit: number = 10
Expand Down Expand Up @@ -138,6 +139,10 @@ export class TopCollectionResolver {
inBuilder.andWhere('collection.category IN (:...category)', { category })
}

if (query) {
inBuilder.andWhere(`collection.metadata->>'name' ILIKE :query`, { query: `%${query}%` })
}

inBuilder
.from(ListingSale, 'sale')
.innerJoin(Listing, 'listing', 'listing.id = sale.listing')
Expand All @@ -155,4 +160,4 @@ export class TopCollectionResolver {

return builder.getRawMany()
}
}
}

Check failure on line 163 in src/server-extension/resolvers/top_collections.ts

View workflow job for this annotation

GitHub Actions / Code Standard & Format

Insert `⏎`

0 comments on commit f9517e8

Please sign in to comment.