Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix #943

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-dingos-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

fixing prisma include issue in updateAllTokenPrices
9 changes: 5 additions & 4 deletions modules/token/lib/token-price.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ export class TokenPriceService {
public async updateAllTokenPrices(chains: Chain[]): Promise<void> {
const tokens = await prisma.prismaToken.findMany({
where: { chain: { in: chains } },
include: {
types: true,
},
});

const tokenTypes = await prisma.prismaTokenType.findMany({
where: { chain: { in: chains } },
});

let tokensWithTypes = tokens.map((token) => ({
...token,
types: token.types.map((type) => type.type),
types: tokenTypes.filter((type) => type.tokenAddress === token.address).map((type) => type.type),
}));

for (const handler of this.priceHandlers) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"prisma-merge": "ts-node prisma/prisma-merge.ts",
"test": "jest",
"vitest": "vitest",
"task": "ts-node -r tsconfig-paths/register -r dotenv/config tasks/index.ts"
"task": "ts-node -r tsconfig-paths/register -r dotenv/config tasks/index.ts",
"mutation": "sh scripts/run_mutation.sh"
},
"dependencies": {
"@aws-sdk/client-cloudwatch": "^3.388.0",
Expand Down
14 changes: 14 additions & 0 deletions scripts/run_mutation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Ensure the mutation query and chainId are passed as arguments
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 '<mutation_query>' '<chainId>'"
exit 1
fi

MUTATION_QUERY=$1
CHAIN_ID=$2
ADMIN_API_KEY=$(grep '^ADMIN_API_KEY=' .env | cut -d '=' -f2)

# Execute the curl command with the provided mutation query and chainId
curl -d "{\"query\":\"mutation { $MUTATION_QUERY }\"}" -H 'Content-Type: application/json' -H "chainId: $CHAIN_ID" -H "AdminApiKey: $ADMIN_API_KEY" http://localhost:4000/graphql
Loading