From 47d2d60b4854e9a5ce100250a591fac8153db635 Mon Sep 17 00:00:00 2001 From: dylanverstraete Date: Mon, 27 Feb 2023 22:38:06 +0100 Subject: [PATCH] fix: node interface parsing and bump 2.9.0-rc7 --- indexer/chart/Chart.yaml | 2 +- package-lock.json | 2 +- package.json | 2 +- processor-chart/Chart.yaml | 2 +- src/mappings/nodes.ts | 33 ++++++++++++--------------------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/indexer/chart/Chart.yaml b/indexer/chart/Chart.yaml index ea99398..5e3972b 100644 --- a/indexer/chart/Chart.yaml +++ b/indexer/chart/Chart.yaml @@ -2,4 +2,4 @@ name: tfchainindexer description: Helm Chart for the tfchain hydra indexer version: 2.7.7 apiVersion: v2 -appVersion: '2.9.0-rc6' +appVersion: '2.9.0-rc7' diff --git a/package-lock.json b/package-lock.json index d18af88..39c2e69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "graphql_tfgrid", - "version": "2.9.0-rc6", + "version": "2.9.0-rc7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a96d206..47bfd52 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "graphql_tfgrid", "private": "true", - "version": "2.9.0-rc6", + "version": "2.9.0-rc7", "description": "GraphQL server and Substrate indexer. Generated with ♥ by Hydra-CLI", "author": "", "license": "ISC", diff --git a/processor-chart/Chart.yaml b/processor-chart/Chart.yaml index 0c8b09b..feada76 100644 --- a/processor-chart/Chart.yaml +++ b/processor-chart/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v2 name: tfchain-processor description: A chart for the tfchain graphql processor and query node version: 1.0.5 -appVersion: '2.9.0-rc6' +appVersion: '2.9.0-rc7' diff --git a/src/mappings/nodes.ts b/src/mappings/nodes.ts index 2adc542..bdd907e 100644 --- a/src/mappings/nodes.ts +++ b/src/mappings/nodes.ts @@ -7,6 +7,7 @@ import { PublicConfig as V105PublicConfig } from '../types/v105' import { Ctx } from '../processor' import assert from "assert"; +import { allowedNodeEnvironmentFlags } from "process"; export async function nodeStored( ctx: Ctx, @@ -139,11 +140,9 @@ export async function nodeStored( newInterface.mac = intf.mac.toString() newInterface.ips = intf.ips.map(ip => ip.toString()).join(',') await ctx.store.save(newInterface) - newNode.interfaces.push(newInterface) }) await Promise.all(interfacesPromisses) - await ctx.store.save(newNode) } export async function nodeUpdated( @@ -319,31 +318,23 @@ export async function nodeUpdated( } } - const interfacesPromisses = nodeEvent.interfaces.map(async intf => { - let newInterface - - if (savedNode.interfaces) { - // if an interface with same name exists - const found = savedNode.interfaces.findIndex(interf => interf.name === intf.name.toString()) - if (found > 0) { - newInterface = savedNode.interfaces[found] - } else { - newInterface = new Interfaces() - newInterface.id = item.event.id - newInterface.node = savedNode - } - } - - if (!newInterface) return + // First remove all ifs + const nodeIfs = await ctx.store.find(Interfaces, { where: { node: { nodeID: savedNode.nodeID } } }) + await ctx.store.remove(nodeIfs) + // Save ones from update event + await Promise.all(nodeEvent.interfaces.map(async intf => { + const newInterface = new Interfaces() + newInterface.id = item.event.id + intf.name.toString() newInterface.name = intf.name.toString() newInterface.mac = intf.mac.toString() newInterface.ips = intf.ips.map(ip => ip.toString()).join(',') - + newInterface.node = savedNode await ctx.store.save(newInterface) + savedNode.interfaces.push(newInterface) - }) - await Promise.all(interfacesPromisses) + })) + await ctx.store.save(savedNode) }