diff --git a/src/components.ts b/src/components.ts index d396e07..06d306b 100644 --- a/src/components.ts +++ b/src/components.ts @@ -35,7 +35,7 @@ import { createWertSigner } from './ports/wert-signer/component' import { AppComponents, GlobalContext } from './types' const thirtySeconds = 30 * 1000 -const fifteenMinutes = 15 * 60 * 1000 +const fiveMinutes = 15 * 60 * 1000 // Initialize all the components of the app export async function initComponents(): Promise { @@ -51,7 +51,7 @@ export async function initComponents(): Promise { const server = await createServerComponent({ config, logs }, { cors }) const statusChecks = await createStatusCheckComponent({ server, config }) const fetch = await createFetchComponent({ tracer }) - const updateBuilderServerItemsViewJob = createJobComponent({ logs }, () => catalog.updateBuilderServerItemsView(), fifteenMinutes, { + const updateBuilderServerItemsViewJob = createJobComponent({ logs }, () => catalog.updateBuilderServerItemsView(), fiveMinutes, { startupDelay: thirtySeconds }) diff --git a/src/ports/catalog/component.ts b/src/ports/catalog/component.ts index fee7a80..d84de39 100644 --- a/src/ports/catalog/component.ts +++ b/src/ports/catalog/component.ts @@ -86,11 +86,11 @@ export async function createCatalogComponent( const client = await database.getPool().connect() try { const query = SQL` - REFRESH MATERIALIZED VIEW CONCURRENTLY ` + REFRESH MATERIALIZED VIEW ` .append(BUILDER_SERVER_TABLE_SCHEMA) .append( SQL`.mv_builder_server_items; - REFRESH MATERIALIZED VIEW CONCURRENTLY ` + REFRESH MATERIALIZED VIEW ` ) .append(BUILDER_SERVER_TABLE_SCHEMA).append(SQL`.mv_builder_server_items_utility; `) diff --git a/src/ports/orders/queries.ts b/src/ports/orders/queries.ts index 62b8028..8043d77 100644 --- a/src/ports/orders/queries.ts +++ b/src/ports/orders/queries.ts @@ -3,6 +3,7 @@ import { OrderFilters, OrderSortBy, TradeType } from '@dcl/schemas' import { ContractName, getContract } from 'decentraland-transactions' import { getEthereumChainId, getPolygonChainId } from '../../logic/chainIds' import { getDBNetworks } from '../../utils' +import { MAX_ORDER_TIMESTAMP } from '../catalog/queries' import { getTradesForTypeQuery } from '../trades/queries' import { getWhereStatementFromFilters } from '../utils' @@ -121,7 +122,11 @@ 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 > EXTRACT(EPOCH FROM now()::timestamptz(3)) ` + const FILTER_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 COMMON_FILTERS = [ FILTER_BY_MARKETPLACE_ADDRESS,