Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ENS filter by owner error and remove limit for prices query #251

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading