Skip to content

Commit

Permalink
Remove query nesting so goldsky doesn't timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn committed Aug 2, 2024
1 parent aaf0c77 commit 1773207
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions tinlake-ui/services/apollo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,43 +292,39 @@ class Apollo {

async getLoans(root: string) {
const result = await this.client.query({
query: gql`
{
pools(where: { id_in: ["${root.toLowerCase()}"]}) {
loans (first: 1000) {
id
pool {
id
}
index
owner
opened
closed
debt
interestRatePerSecond
ceiling
threshold
borrowsCount
borrowsAggregatedAmount
repaysCount
repaysAggregatedAmount
nftId
nftRegistry
maturityDate
financingDate
riskGroup
}
query: gql`
{
loans(
where: {pool_: {id: "${root.toLowerCase()}"}}
first: 1000
) {
id
pool {
id
}
index
owner
opened
closed
debt
interestRatePerSecond
ceiling
threshold
borrowsCount
borrowsAggregatedAmount
repaysCount
repaysAggregatedAmount
nftId
nftRegistry
maturityDate
financingDate
riskGroup
}
}
`,
})

const loans = result.data.pools.reduce((assets: any[], pool: any) => {
if (pool.loans) {
assets.push(...pool.loans)
}
return assets
}, [])
const loans = result.data.loans

if (!loans) return { data: [] }

Expand Down

0 comments on commit 1773207

Please sign in to comment.