mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
add user totalSales and totalOrders (#333)
This commit is contained in:
parent
cd27a2432d
commit
dfb59ae6fd
@ -281,6 +281,12 @@ type User @entity {
|
|||||||
poolTransactions: [PoolTransaction!] @derivedFrom(field: "user")
|
poolTransactions: [PoolTransaction!] @derivedFrom(field: "user")
|
||||||
orders: [Order!] @derivedFrom(field: "payer")
|
orders: [Order!] @derivedFrom(field: "payer")
|
||||||
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
|
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
|
||||||
|
|
||||||
|
"total number of orders made by this user"
|
||||||
|
totalOrders: BigInt!
|
||||||
|
|
||||||
|
"total number of orders made on assets owned by this user"
|
||||||
|
totalSales: BigInt!
|
||||||
}
|
}
|
||||||
|
|
||||||
type FixedRateExchange @entity {
|
type FixedRateExchange @entity {
|
||||||
|
@ -38,6 +38,8 @@ export function handleOrderStarted(event: OrderStarted): void {
|
|||||||
order.consumer = consumer.id
|
order.consumer = consumer.id
|
||||||
|
|
||||||
const payer = getUser(event.params.payer.toHex())
|
const payer = getUser(event.params.payer.toHex())
|
||||||
|
payer.totalOrders = payer.totalOrders.plus(integer.ONE)
|
||||||
|
payer.save()
|
||||||
order.payer = payer.id
|
order.payer = payer.id
|
||||||
|
|
||||||
order.amount = weiToDecimal(
|
order.amount = weiToDecimal(
|
||||||
@ -66,6 +68,9 @@ export function handleOrderStarted(event: OrderStarted): void {
|
|||||||
nft.orderCount = nft.orderCount.plus(integer.ONE)
|
nft.orderCount = nft.orderCount.plus(integer.ONE)
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
const owner = getUser(nft.owner)
|
||||||
|
owner.totalSales = owner.totalSales.plus(integer.ONE)
|
||||||
|
owner.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user