Skip to content

Commit

Permalink
Added activeSubgraphCount and removed null asignement to currentVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmardefago committed Jul 13, 2021
1 parent 0899edb commit 5b86ff8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ type GraphNetwork @entity {
activeDelegationCount: Int!
"Total curators"
curatorCount: Int!
"Total subgraphs"
"Total amount of Subgraph entities"
subgraphCount: Int!
"Total subgraphs"
"Amount of active Subgraph entities"
activeSubgraphCount: Int!
"Total amount of SubgraphDeployment entities"
subgraphDeploymentCount: Int!
"Total epochs"
epochCount: Int!
Expand Down
5 changes: 4 additions & 1 deletion src/mappings/gns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ export function handleSubgraphDeprecated(event: SubgraphDeprecated): void {
let subgraphID = joinID([graphAccount, subgraphNumber])
let subgraph = Subgraph.load(subgraphID)

subgraph.currentVersion = null
subgraph.active = false
subgraph.updatedAt = event.block.timestamp.toI32()
subgraph.save()

let graphNetwork = GraphNetwork.load('1')
graphNetwork.activeSubgraphCount = graphNetwork.activeSubgraphCount - 1
graphNetwork.save()
}

export function handleNameSignalEnabled(event: NameSignalEnabled): void {
Expand Down
2 changes: 2 additions & 0 deletions src/mappings/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function createOrLoadSubgraph(

let graphNetwork = GraphNetwork.load('1')
graphNetwork.subgraphCount = graphNetwork.subgraphCount + 1
graphNetwork.activeSubgraphCount = graphNetwork.activeSubgraphCount + 1
graphNetwork.save()
}
return subgraph as Subgraph
Expand Down Expand Up @@ -509,6 +510,7 @@ export function createOrLoadGraphNetwork(
graphNetwork.curatorCount = 0
graphNetwork.subgraphCount = 0
graphNetwork.subgraphDeploymentCount = 0
graphNetwork.activeSubgraphCount = 0

graphNetwork.arbitrator = Address.fromString('0x0000000000000000000000000000000000000000')
graphNetwork.querySlashingPercentage = 0
Expand Down

0 comments on commit 5b86ff8

Please sign in to comment.