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")
|
sharesOwned: [PoolShare!] @derivedFrom(field: "userAddress")
|
||||||
tokenBalancesOwned: [TokenBalance!] @derivedFrom(field: "userAddress")
|
tokenBalancesOwned: [TokenBalance!] @derivedFrom(field: "userAddress")
|
||||||
tokensOwned: [Datatoken!] @derivedFrom(field: "minter")
|
tokensOwned: [Datatoken!] @derivedFrom(field: "minter")
|
||||||
|
nrSales: Int
|
||||||
poolTransactions: [PoolTransaction!] @derivedFrom(field: "userAddress")
|
poolTransactions: [PoolTransaction!] @derivedFrom(field: "userAddress")
|
||||||
poolTransactionsTokenValues: [PoolTransactionTokenValues!]
|
poolTransactionsTokenValues: [PoolTransactionTokenValues!]
|
||||||
@derivedFrom(field: "userAddress")
|
@derivedFrom(field: "userAddress")
|
||||||
|
@ -237,6 +237,7 @@ export function updatePoolSwapVolume(
|
|||||||
export function createUserEntity(address: string): void {
|
export function createUserEntity(address: string): void {
|
||||||
if (User.load(address) == null) {
|
if (User.load(address) == null) {
|
||||||
const user = new User(address)
|
const user = new User(address)
|
||||||
|
user.nrSales = 0
|
||||||
user.save()
|
user.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ import {
|
|||||||
Global,
|
Global,
|
||||||
PoolFactory,
|
PoolFactory,
|
||||||
TokenBalance,
|
TokenBalance,
|
||||||
TokenOrder
|
TokenOrder,
|
||||||
|
User
|
||||||
} from '../@types/schema'
|
} from '../@types/schema'
|
||||||
import {
|
import {
|
||||||
tokenToDecimal,
|
tokenToDecimal,
|
||||||
@ -155,6 +156,11 @@ export function handleOrderStarted(event: OrderStarted): void {
|
|||||||
factory.orderCount = factory.orderCount.plus(BigInt.fromI32(1))
|
factory.orderCount = factory.orderCount.plus(BigInt.fromI32(1))
|
||||||
factory.totalOrderVolume = factory.totalOrderVolume.plus(order.amount)
|
factory.totalOrderVolume = factory.totalOrderVolume.plus(order.amount)
|
||||||
factory.save()
|
factory.save()
|
||||||
|
|
||||||
|
const user = User.load(datatoken.minter)
|
||||||
|
user.nrSales = user.nrSales + 1
|
||||||
|
user.save()
|
||||||
|
|
||||||
const gStats: Global | null = getGlobalStats()
|
const gStats: Global | null = getGlobalStats()
|
||||||
gStats.orderCount = factory.orderCount
|
gStats.orderCount = factory.orderCount
|
||||||
gStats.totalOrderVolume = factory.totalOrderVolume
|
gStats.totalOrderVolume = factory.totalOrderVolume
|
||||||
|
Loading…
Reference in New Issue
Block a user