Skip to content

Commit

Permalink
fix: ENS filter by owner error and remove limit for prices query
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Jan 24, 2025
1 parent 74745ea commit 2d73474
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/ports/nfts/ensQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function geENSWhereStatement(nftFilters: GetNFTsFilters): SQLStatement {
}

const ownerEthereumAddress = nftFilters.owner ? `${nftFilters.owner.toLocaleLowerCase()}-ETHEREUM` : null
const FILTER_BY_OWNER = nftFilters.owner ? SQL` owner_id = ${ownerEthereumAddress}` : null
const FILTER_BY_OWNER = nftFilters.owner ? SQL` nft.owner_id = ${ownerEthereumAddress}` : null

const FILTER_BY_TOKEN_ID = nftFilters.tokenId ? SQL` token_id = ${nftFilters.tokenId} ` : null
const FILTER_BY_SEARCH = nftFilters.search ? SQL` search_text % ${nftFilters.search} ` : null
Expand All @@ -31,7 +31,7 @@ function geENSWhereStatement(nftFilters: GetNFTsFilters): SQLStatement {
])
}

export function getENSs(nftFilters: GetNFTsFilters): SQLStatement {
export function getENSs(nftFilters: GetNFTsFilters, uncapped = false): SQLStatement {
const { sortBy, isOnSale, ids } = nftFilters
return SQL`
WITH filtered_ens_nfts AS (
Expand Down Expand Up @@ -106,8 +106,8 @@ export function getENSs(nftFilters: GetNFTsFilters): SQLStatement {
`
.append(isOnSale ? SQL`LEFT JOIN valid_orders orders ON orders.nft_id = nft.id` : SQL``)
.append(geENSWhereStatement(nftFilters))
.append(getNFTsSortBy(sortBy))
.append(getNFTLimitAndOffsetStatement(nftFilters))
.append(sortBy ? getNFTsSortBy(sortBy) : SQL``)
.append(uncapped ? SQL`` : getNFTLimitAndOffsetStatement(nftFilters))
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/ports/nfts/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export function getNFTsQuery(nftFilters: GetNFTsFilters & { rentalAssetsIds?: st
if (nftFilters.isLand || nftFilters.category === NFTCategory.PARCEL || nftFilters.category === NFTCategory.ESTATE) {
return nftFilters.isOnSale ? getLandsOnSaleQuery(nftFilters) : getAllLANDsQuery(nftFilters)
} else if (nftFilters.category === NFTCategory.ENS) {
return getENSs(nftFilters)
return getENSs(nftFilters, uncapped)
} else if (nftFilters.sortBy === NFTSortBy.RECENTLY_LISTED) {
return getRecentlyListedNFTsQuery(nftFilters)
}
Expand Down
2 changes: 1 addition & 1 deletion src/ports/prices/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getPricesQuery(filters: PriceFilters) {
...fromPriceFiltersToNFTFilters(filters),
isOnSale: true
}
return SQL`SELECT price FROM (`.append(getNFTsQuery({ ...nftFilters, sortBy: undefined })).append(SQL`) as nfts`)
return SQL`SELECT price FROM (`.append(getNFTsQuery({ ...nftFilters, sortBy: undefined }, true)).append(SQL`) as nfts`)
}

const catalogFilters = {
Expand Down

0 comments on commit 2d73474

Please sign in to comment.