Skip to content

Commit

Permalink
Merge pull request #196 from decentraland/fix/old-orders-filter
Browse files Browse the repository at this point in the history
fix: filter the old orders correctly
  • Loading branch information
juanmahidalgo authored Dec 10, 2024
2 parents d07200a + 1bb0aac commit c7ee971
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppComponents> {
Expand All @@ -51,7 +51,7 @@ export async function initComponents(): Promise<AppComponents> {
const server = await createServerComponent<GlobalContext>({ 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
})

Expand Down
4 changes: 2 additions & 2 deletions src/ports/catalog/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
`)
Expand Down
7 changes: 6 additions & 1 deletion src/ports/orders/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c7ee971

Please sign in to comment.