diff --git a/CHANGELOG.md b/CHANGELOG.md index 678e4d4c..2358b733 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # backend +## 1.14.8 + +### Patch Changes + +- ac4ff07: make queries to use wallet indexes properly + ## 1.14.7 ### Patch Changes diff --git a/modules/pool/lib/pool-gql-loader.service.ts b/modules/pool/lib/pool-gql-loader.service.ts index 12c2bbc3..260f0ccb 100644 --- a/modules/pool/lib/pool-gql-loader.service.ts +++ b/modules/pool/lib/pool-gql-loader.service.ts @@ -334,7 +334,7 @@ export class PoolGqlLoaderService { orderBy = { dynamicData: { totalLiquidity: orderDirection } }; break; case 'totalShares': - orderBy = { dynamicData: { totalShares: orderDirection } }; + orderBy = { dynamicData: { totalSharesNum: orderDirection } }; break; case 'volume24h': orderBy = { dynamicData: { volume24h: orderDirection } }; @@ -372,7 +372,7 @@ export class PoolGqlLoaderService { } const where = args.where; - const textSearch = args.textSearch ? { contains: args.textSearch, mode: 'insensitive' as const } : undefined; + const textSearch = args.textSearch ? { contains: args.textSearch.toLowerCase() } : undefined; const allTokensFilter = []; where?.tokensIn?.forEach((token) => { @@ -381,8 +381,7 @@ export class PoolGqlLoaderService { some: { token: { address: { - equals: token, - mode: 'insensitive' as const, + equals: token.toLowerCase(), }, }, }, @@ -396,8 +395,7 @@ export class PoolGqlLoaderService { every: { token: { address: { - notIn: where.tokensNotIn || undefined, - mode: 'insensitive' as const, + notIn: where.tokensNotIn.map((t) => t.toLowerCase()) || undefined, }, }, }, @@ -412,8 +410,7 @@ export class PoolGqlLoaderService { userWalletBalances: { some: { userAddress: { - equals: userAddress, - mode: 'insensitive' as const, + equals: userAddress.toLowerCase(), }, balanceNum: { gt: 0 }, }, @@ -423,8 +420,7 @@ export class PoolGqlLoaderService { userStakedBalances: { some: { userAddress: { - equals: userAddress, - mode: 'insensitive' as const, + equals: userAddress.toLowerCase(), }, balanceNum: { gt: 0 }, }, @@ -460,9 +456,8 @@ export class PoolGqlLoaderService { }, AND: allTokensFilter, id: { - in: where?.idIn || undefined, - notIn: where?.idNotIn || undefined, - mode: 'insensitive', + in: where?.idIn?.map((id) => id.toLowerCase()) || undefined, + notIn: where?.idNotIn?.map((id) => id.toLowerCase()) || undefined, }, ...(where?.categoryIn && !where?.tagIn ? { categories: { hasSome: where.categoryIn.map((s) => s.toUpperCase()) } } @@ -1324,8 +1319,7 @@ export class PoolGqlLoaderService { userStakedBalances: { where: { userAddress: { - equals: userAddress, - mode: 'insensitive' as const, + equals: userAddress.toLowerCase(), }, balanceNum: { gt: 0 }, }, @@ -1335,8 +1329,7 @@ export class PoolGqlLoaderService { userWalletBalances: { where: { userAddress: { - equals: userAddress, - mode: 'insensitive' as const, + equals: userAddress.toLowerCase(), }, balanceNum: { gt: 0 }, }, diff --git a/package.json b/package.json index af7a1dd4..b5289d3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backend", - "version": "1.14.7", + "version": "1.14.8", "description": "Backend service for Beethoven X and Balancer", "repository": "https://github.com/balancer/backend", "author": "Beethoven X", diff --git a/prisma/migrations/20240830154431_dynamic_data_index/migration.sql b/prisma/migrations/20240830154431_dynamic_data_index/migration.sql new file mode 100644 index 00000000..c387cf20 --- /dev/null +++ b/prisma/migrations/20240830154431_dynamic_data_index/migration.sql @@ -0,0 +1,5 @@ +-- DropIndex +DROP INDEX "PrismaPoolDynamicData_totalShares_idx"; + +-- CreateIndex +CREATE INDEX "PrismaPoolDynamicData_totalSharesNum_idx" ON "PrismaPoolDynamicData"("totalSharesNum" DESC); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9224bee1..40701e40 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -141,7 +141,7 @@ model PrismaPoolDynamicData { @@unique([poolId, chain]) // Indexes used for sorting pools in the UI by different metrics @@index(totalLiquidity) - @@index(totalShares) + @@index(totalSharesNum(sort: Desc)) @@index(volume24h) @@index(apr) diff --git a/prisma/schema/pool.prisma b/prisma/schema/pool.prisma index 669a3b1f..43c75697 100644 --- a/prisma/schema/pool.prisma +++ b/prisma/schema/pool.prisma @@ -67,7 +67,7 @@ model PrismaPoolDynamicData { @@unique([poolId, chain]) // Indexes used for sorting pools in the UI by different metrics @@index(totalLiquidity) - @@index(totalShares) + @@index(totalSharesNum(sort: Desc)) @@index(volume24h) @@index(apr)