diff --git a/lib/constants/index.ts b/lib/constants/index.ts index 888652964..75a23e787 100644 --- a/lib/constants/index.ts +++ b/lib/constants/index.ts @@ -3,7 +3,9 @@ import resolveTailwindConfig from "tailwindcss/resolveConfig"; import tailwindConfig from "../../tailwind.config"; import { EndpointOption, Environment } from "../types"; -export const isWSX = process.env.NEXT_PUBLIC_CLIENT === "wsx"; +// IMPORTANT: this should be false for all other branches other than the wsx branch. +export const isWSX = false; + export const wsxID = process.env.NEXT_PUBLIC_VERCEL_ENV === "staging" ? 3 : 3; export const wsxAssetIdString = `{"foreignAsset":${wsxID}}`; diff --git a/lib/gql/trending-markets.ts b/lib/gql/trending-markets.ts index 90f835bba..d5aa6a45d 100644 --- a/lib/gql/trending-markets.ts +++ b/lib/gql/trending-markets.ts @@ -21,6 +21,7 @@ import { getCurrentPrediction } from "lib/util/assets"; import { fetchAllPages } from "lib/util/fetch-all-pages"; import { parseAssetIdString } from "lib/util/parse-asset-id"; import { marketMetaFilter } from "./constants"; +import { isNotNull } from "@zeitgeistpm/utility/dist/null"; const poolChangesQuery = gql` query PoolChanges($start: DateTime, $end: DateTime) { @@ -45,6 +46,8 @@ const marketQuery = gql` where: { pool: { poolId_eq: $poolId } marketId_not_in: ${hiddenMarketIds} + hasValidMetaCategories_eq: true + categories_isNull: false ${marketMetaFilter} } ) { @@ -149,6 +152,11 @@ const getTrendingMarkets = async ( const market = marketsRes.markets[0]; + if (!market) { + console.log("No market"); + return null; + } + const assetsRes = await client.request<{ assets: { pool: { poolId: number }; @@ -163,6 +171,11 @@ const getTrendingMarkets = async ( const prediction = getCurrentPrediction(assets, market); + if (!market.categories) { + console.log("No categories for market", market.marketId); + return null; + } + const marketCategories: MarketOutcomes = market.categories.map( (category, index) => { const asset = assets[index]; @@ -198,7 +211,7 @@ const getTrendingMarkets = async ( }), ); - return trendingMarkets; + return trendingMarkets.filter(isNotNull); }; const lookupPrice = (