1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Fix Profile sold value (#840)

* update profile sold value logic

* remove commented block
This commit is contained in:
Bogdan Fazakas 2021-09-07 13:11:13 +03:00 committed by GitHub
parent c9f56e9a46
commit 5a336bd699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 12 deletions

View File

@ -52,17 +52,16 @@ export default function Stats({
const result = await queryMetadata(queryPublishedAssets, source.token)
setPublishedAssets(result.results)
setNumberOfAssets(result.totalResults)
const nrOrders = await getAccountNumberOfOrders(
result.results,
chainIds
)
setSold(nrOrders)
} catch (error) {
Logger.error(error.message)
}
}
getPublished()
async function getAccountSoldValue() {
const nrOrders = await getAccountNumberOfOrders(accountId, chainIds)
setSold(nrOrders)
}
getAccountSoldValue()
}, [accountId, chainIds])
useEffect(() => {

View File

@ -167,15 +167,18 @@ const HighestLiquidityAssets = gql`
`
const TotalAccountOrders = gql`
query TotalAccountOrders($payer: String) {
tokenOrders(orderBy: id, where: { payer: $payer }) {
id
query TotalAccountOrders($datatokenId_in: [String!]) {
tokenOrders(where: { datatokenId_in: $datatokenId_in }) {
payer {
id
}
datatokenId {
id
}
}
}
`
const UserSharesQuery = gql`
query UserSharesQuery($user: String, $pools: [String!]) {
poolShares(where: { userAddress: $user, poolId_in: $pools }) {
@ -564,11 +567,15 @@ export async function getHighestLiquidityDIDs(
}
export async function getAccountNumberOfOrders(
accountId: string,
assets: DDO[],
chainIds: number[]
): Promise<number> {
const datatokens: string[] = []
assets.forEach((ddo) => {
datatokens.push(ddo?.dataToken?.toLowerCase())
})
const queryVariables = {
payer: accountId.toLowerCase()
datatokenId_in: datatokens
}
const results = await fetchDataForMultipleChains(
TotalAccountOrders,
@ -577,7 +584,7 @@ export async function getAccountNumberOfOrders(
)
let numberOfOrders = 0
for (const result of results) {
numberOfOrders += result.tokenOrders.length
numberOfOrders += result?.tokenOrders?.length
}
return numberOfOrders
}