From 5b86ff8d4016219e7bbac823957efcb1949de746 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 8 Jul 2021 19:28:16 -0300 Subject: [PATCH] Added activeSubgraphCount and removed null asignement to currentVersion --- schema.graphql | 6 ++++-- src/mappings/gns.ts | 5 ++++- src/mappings/helpers.ts | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/schema.graphql b/schema.graphql index 2664c560..b1d1f454 100644 --- a/schema.graphql +++ b/schema.graphql @@ -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! diff --git a/src/mappings/gns.ts b/src/mappings/gns.ts index df41ab16..232f711e 100644 --- a/src/mappings/gns.ts +++ b/src/mappings/gns.ts @@ -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 { diff --git a/src/mappings/helpers.ts b/src/mappings/helpers.ts index 4c712e2b..da467248 100644 --- a/src/mappings/helpers.ts +++ b/src/mappings/helpers.ts @@ -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 @@ -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