From 8a49549565712400b62a8e106252543861cdf749 Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Tue, 10 Dec 2024 21:36:13 +0100 Subject: [PATCH 1/2] fix: trades with no price --- src/ports/orders/queries.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ports/orders/queries.ts b/src/ports/orders/queries.ts index 3a9ec62..c198a65 100644 --- a/src/ports/orders/queries.ts +++ b/src/ports/orders/queries.ts @@ -122,11 +122,12 @@ function getOrdersAndTradesFilters(filters: OrderFilters & { nftIds?: string[] } const FILTER_TRADE_BY_ITEM_ID = filters.itemId ? SQL` item_id = ${filters.itemId} ` : null const FILTER_BY_NFT_NAME = filters.nftName ? SQL` LOWER(nft_name) = LOWER(${filters.nftName}) ` : null const FILTER_BY_NFT_ID = filters.nftIds ? SQL` nft_id = ANY(${filters.nftIds}) ` : null - const FILTER_NOT_EXPIRED = SQL` expires_at < `.append(MAX_ORDER_TIMESTAMP).append( + const FILTER_ORDER_NOT_EXPIRED = SQL` expires_at < `.append(MAX_ORDER_TIMESTAMP).append( SQL` AND ((LENGTH(expires_at::text) = 13 AND TO_TIMESTAMP(expires_at / 1000.0) > NOW()) OR (LENGTH(expires_at::text) = 10 AND TO_TIMESTAMP(expires_at) > NOW())) ` ) + const FILTER_TRADE_NOT_EXPIRED = SQL` expires_at > EXTRACT(EPOCH FROM now()::timestamptz(3)) ` const COMMON_FILTERS = [ FILTER_BY_MARKETPLACE_ADDRESS, @@ -138,11 +139,10 @@ function getOrdersAndTradesFilters(filters: OrderFilters & { nftIds?: string[] } FILTER_BY_NETWORK, FILTER_BY_NFT_NAME, FILTER_BY_NFT_ID, - FILTER_NOT_EXPIRED ] return { - orders: [...COMMON_FILTERS, FILTER_ORDER_BY_ITEM_ID], - trades: [...COMMON_FILTERS, FILTER_TRADE_BY_ITEM_ID] + orders: [...COMMON_FILTERS, FILTER_ORDER_BY_ITEM_ID, FILTER_ORDER_NOT_EXPIRED], + trades: [...COMMON_FILTERS, FILTER_TRADE_BY_ITEM_ID, FILTER_TRADE_NOT_EXPIRED] } } From 6f12117b4eb5b0ba3c849b7b921cd48d098e0fe5 Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Tue, 10 Dec 2024 21:39:38 +0100 Subject: [PATCH 2/2] fix: lint issue --- src/ports/orders/queries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ports/orders/queries.ts b/src/ports/orders/queries.ts index c198a65..e8f948b 100644 --- a/src/ports/orders/queries.ts +++ b/src/ports/orders/queries.ts @@ -138,7 +138,7 @@ function getOrdersAndTradesFilters(filters: OrderFilters & { nftIds?: string[] } FILTER_BY_STATUS, FILTER_BY_NETWORK, FILTER_BY_NFT_NAME, - FILTER_BY_NFT_ID, + FILTER_BY_NFT_ID ] return { orders: [...COMMON_FILTERS, FILTER_ORDER_BY_ITEM_ID, FILTER_ORDER_NOT_EXPIRED],