mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
add nr of sales for user (#231)
This commit is contained in:
parent
1abd5324a4
commit
ec0c282658
@ -214,6 +214,7 @@ type User @entity {
|
||||
sharesOwned: [PoolShare!] @derivedFrom(field: "userAddress")
|
||||
tokenBalancesOwned: [TokenBalance!] @derivedFrom(field: "userAddress")
|
||||
tokensOwned: [Datatoken!] @derivedFrom(field: "minter")
|
||||
nrSales: Int
|
||||
poolTransactions: [PoolTransaction!] @derivedFrom(field: "userAddress")
|
||||
poolTransactionsTokenValues: [PoolTransactionTokenValues!]
|
||||
@derivedFrom(field: "userAddress")
|
||||
|
@ -237,6 +237,7 @@ export function updatePoolSwapVolume(
|
||||
export function createUserEntity(address: string): void {
|
||||
if (User.load(address) == null) {
|
||||
const user = new User(address)
|
||||
user.nrSales = 0
|
||||
user.save()
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ import {
|
||||
Global,
|
||||
PoolFactory,
|
||||
TokenBalance,
|
||||
TokenOrder
|
||||
TokenOrder,
|
||||
User
|
||||
} from '../@types/schema'
|
||||
import {
|
||||
tokenToDecimal,
|
||||
@ -155,6 +156,11 @@ export function handleOrderStarted(event: OrderStarted): void {
|
||||
factory.orderCount = factory.orderCount.plus(BigInt.fromI32(1))
|
||||
factory.totalOrderVolume = factory.totalOrderVolume.plus(order.amount)
|
||||
factory.save()
|
||||
|
||||
const user = User.load(datatoken.minter)
|
||||
user.nrSales = user.nrSales + 1
|
||||
user.save()
|
||||
|
||||
const gStats: Global | null = getGlobalStats()
|
||||
gStats.orderCount = factory.orderCount
|
||||
gStats.totalOrderVolume = factory.totalOrderVolume
|
||||
|
Loading…
Reference in New Issue
Block a user