Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecot committed Aug 29, 2024
1 parent 3c7646a commit bccf911
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@ query_endpoints_full_tests_staging:
cd tests/query_endpoints && make query_endpoints_full_tests_staging

query_endpoints_full_tests_testnet:
cd tests/query_endpoints && make query_endpoints_full_tests_testnet
cd tests/query_endpoints && make query_endpoints_full_tests_testnet

query_endpoints_full_tests_mainnet:
cd tests/query_endpoints && make query_endpoints_full_tests_mainnet
15 changes: 11 additions & 4 deletions src/query/handlers/index/indexProvidersActiveHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class IndexProvidersActiveData extends RequestHandlerBase<IndexProvidersActiveRe
}

protected async getActiveProviderAddresses(): Promise<string[]> {
const data = await QueryGetJsinfoReadDbInstance()
const data1 = QueryGetJsinfoReadDbInstance()
.select({
provider: JsinfoSchema.providerStakes.provider,
})
Expand All @@ -154,10 +154,15 @@ class IndexProvidersActiveData extends RequestHandlerBase<IndexProvidersActiveRe
.having(
and(
gt(sql<number>`MAX(${JsinfoProviderAgrSchema.aggDailyRelayPayments.dateday})`, sql`NOW() - INTERVAL '30 day'`),
gt(sql<number>`COALESCE(SUM(${JsinfoProviderAgrSchema.aggDailyRelayPayments.relaySum}), 0)`, 100)
gt(sql<number>`COALESCE(SUM(${JsinfoProviderAgrSchema.aggDailyRelayPayments.relaySum}), 0)`, 1)
)
)

console.log("data1.toSQL()", data1.toSQL())

const data = await data1;
console.log("getActiveProviderAddresses", data)

return data.map(item => item.provider).filter((provider): provider is string => provider !== null);
}

Expand Down Expand Up @@ -193,13 +198,15 @@ class IndexProvidersActiveData extends RequestHandlerBase<IndexProvidersActiveRe

let activeProviders = await this.getActiveProviderAddresses();

const res = await QueryGetJsinfoReadDbInstance()
const res1 = QueryGetJsinfoReadDbInstance()
.select({
count: sql<number>`COUNT(DISTINCT ${JsinfoSchema.providerStakes.provider})`,
})
.from(JsinfoSchema.providerStakes)
.where(inArray(JsinfoSchema.providers.address, activeProviders))
.where(inArray(JsinfoSchema.providerStakes.provider, activeProviders))

console.log("res1", res1.toSQL())
const res = await res1;
return res[0].count || 0;
}

Expand Down

0 comments on commit bccf911

Please sign in to comment.