Skip to content

Commit

Permalink
Merge pull request #240 from decentraland/feat/use-right-expires-at-n…
Browse files Browse the repository at this point in the history
…ormalized-field

feat: use expires_at_normalized field
  • Loading branch information
juanmahidalgo authored Jan 7, 2025
2 parents 0e08f0e + e76e670 commit 0b68bae
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ports/catalog/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ export const getCollectionsItemsCatalogQueryWithTrades = (filters: CatalogQueryF
SQL`.order AS orders
WHERE
orders.status = 'open'
AND orders.expires_normalized > NOW() `
AND orders.expires_at_normalized > NOW() AND nft.owner_address = orders.owner`
)
)
.append(getOrderRangePriceWhere(filters))
Expand Down
4 changes: 2 additions & 2 deletions src/ports/nfts/ensQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export function getENSs(nftFilters: GetNFTsFilters): SQLStatement {
SELECT
o.nft_id,
o.status,
o.expires_normalized
o.expires_at_normalized
FROM
squid_marketplace.order o
WHERE
o.status = 'open'
AND o.expires_normalized > now()
AND o.expires_at_normalized > now()
)`
: SQL``
)
Expand Down
4 changes: 2 additions & 2 deletions src/ports/nfts/landQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function getAllLANDWheres(filters: GetNFTsFilters & { rentalAssetsIds?: string[]

function getOpenOrderNFTsCTE(filters: GetNFTsFilters): SQLStatement {
const FILTER_IS_ON_SALE = filters.isOnSale
? SQL`nft.active_order_id IS NOT NULL AND o.status = 'open' AND o.expires_normalized > NOW()`
? SQL`nft.active_order_id IS NOT NULL AND o.status = 'open' AND o.expires_at_normalized > NOW()`
: null

const {
Expand Down Expand Up @@ -306,7 +306,7 @@ export function getAllLANDsQuery(filters: GetNFTsFilters) {
JOIN squid_marketplace.nft nft ON nft.id = top_land.id
JOIN squid_marketplace."order" o ON nft.active_order_id = o.id
WHERE o.status = 'open'
AND o.expires_normalized > NOW()
AND o.expires_at_normalized > NOW()
)`
.append(getTradesCTE(filters))
.append(getOpenTradesCTE(filters))
Expand Down
4 changes: 2 additions & 2 deletions src/ports/nfts/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ function getRecentlyListedNFTsCTE(nftFilters: GetNFTsFilters): SQLStatement {
FROM squid_marketplace."order"
WHERE
status = 'open'
AND expires_normalized > NOW()
AND expires_at_normalized > NOW()
`
.append(
nftFilters.isLand
Expand All @@ -635,7 +635,7 @@ function getRecentlyListedNFTsCTE(nftFilters: GetNFTsFilters): SQLStatement {
)
.append(
SQL`
ORDER BY expires_normalized DESC NULLS LAST
ORDER BY expires_at_normalized DESC NULLS LAST
LIMIT 24
),
nfts_with_orders AS (
Expand Down
2 changes: 1 addition & 1 deletion src/ports/orders/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function getOrdersAndTradesFilters(filters: OrderFilters & { nftIds?: string[] }
const FILTER_ORDER_BY_ITEM_ID = filters.itemId ? SQL` ord.item_id = ${`${filters.contractAddress}-${filters.itemId}`} ` : null
const FILTER_TRADE_BY_ITEM_ID = filters.itemId ? SQL` item_id = ${filters.itemId} ` : null
const FILTER_BY_NFT_ID = filters.nftIds ? SQL` nft_id = ANY(${filters.nftIds}) ` : null
const FILTER_ORDER_NOT_EXPIRED = SQL` expires_normalized > NOW() `
const FILTER_ORDER_NOT_EXPIRED = SQL` expires_at_normalized > NOW() `
const FILTER_TRADE_NOT_EXPIRED = SQL` expires_at > EXTRACT(EPOCH FROM now()::timestamptz(3)) `

const COMMON_FILTERS = [
Expand Down

0 comments on commit 0b68bae

Please sign in to comment.