Skip to content

Commit

Permalink
feat: track historical power events (#165)
Browse files Browse the repository at this point in the history
* feat: track historical power events

* change newPowerStatus field to newPowerState
  • Loading branch information
sameh-farouk authored May 7, 2024
1 parent 8019ad2 commit 9e8000a
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 440 deletions.
13 changes: 13 additions & 0 deletions db/migrations/1715092202895-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = class Data1715092202895 {
name = 'Data1715092202895'

async up(db) {
await db.query(`CREATE TABLE "power_target_report" ("id" character varying NOT NULL, "farm_id" integer NOT NULL, "node_id" integer NOT NULL, "new_power_target" character varying(4) NOT NULL, "block" integer NOT NULL, "timestamp" numeric NOT NULL, CONSTRAINT "PK_815b6f599146c615b13292a875a" PRIMARY KEY ("id"))`)
await db.query(`CREATE TABLE "power_state_report" ("id" character varying NOT NULL, "farm_id" integer NOT NULL, "node_id" integer NOT NULL, "new_power_state" character varying(4) NOT NULL, "block" integer NOT NULL, "timestamp" numeric NOT NULL, CONSTRAINT "PK_040bf595115174cdc7070b39688" PRIMARY KEY ("id"))`)
}

async down(db) {
await db.query(`DROP TABLE "power_target_report"`)
await db.query(`DROP TABLE "power_state_report"`)
}
}
147 changes: 2 additions & 145 deletions indexer/chart/templates/indexer-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -562,153 +562,10 @@ data:
},
{
"minmax": [
105,
101,
null
],
"types": {
"Contract": {
"version": " u32",
"state": "ContractState",
"contractId": "u64",
"twinId": "u32",
"contractType": "ContractData",
"solutionProviderID": "Option<U64>"
}
}
},
{
"minmax": [
118,
null
],
"types": {
"Node": {
"version": "u32",
"id": "u32",
"farmId": "u32",
"twinId": "u32",
"resources": "Resources",
"location": "Location",
"country": "Vec<u8>",
"city": "Vec<u8>",
"publicConfig": "Option<PublicConfig>",
"created": "u64",
"farmingPolicyId": "u32",
"interfaces": "Vec<Interface>",
"certification": "NodeCertification",
"secureBoot": "bool",
"virtualized": "bool",
"serialNumber": "Option<Vec<u8>>",
"connectionPrice": "u32"
},
"Location": {
"city": "Vec<u8>",
"country": "Vec<u8>",
"latitude": "Vec<u8>",
"longitude": "Vec<u8>"
}
}
},
{
"minmax": [
122,
null
],
"types": {
"ServiceContract": {
"serviceContractId": "u64",
"serviceTwinId:": "u32",
"consumerTwinId": "u32",
"baseFee": "u64",
"variableFee": "u64",
"metadata": "Vec<u8>",
"acceptedByService": "bool",
"acceptedByConsumer": "bool",
"lastBill": "u64",
"state": "ServiceContractState"
},
"ServiceContractState": {
"_enum": {
"Created": null,
"AgreementReady": null,
"ApprovedByBoth": null
}
},
"ServiceContractBill": {
"variableAmount": "u64",
"window": "u64",
"metadata": "Vec<u8>"
}
}
},
{
"minmax": [
124,
null
],
"types": {
"Twin": {
"id": "u32",
"accountId": "AccountId",
"relay": "Vec<u8>",
"entities": "Vec<EntityProof>",
"pk": "Vec<u8>"
}
}
},
{
"minmax": [
125,
null
],
"types": {
"NodePower": {
"state": "PowerState",
"target": "Power"
},
"PowerState": {
"_enum": {
"Up": null,
"Down": "BlockNumber"
}
},
"Power": {
"_enum": [
"Up",
"Down"
]
}
}
},
{
"minmax": [
147,
147
],
"types": {
"Cause": {
"_enum": [
"CanceledByCollective",
"CanceledByUser",
"OutOfFunds"
]
}
}
},
{
"minmax": [
148,
null
],
"types": {
"Cause": {
"_enum": [
"CanceledByUser",
"OutOfFunds",
"CanceledByCollective"
]
}
}
"types": {}
}
]
}
Expand Down
147 changes: 2 additions & 145 deletions indexer/typesBundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -559,153 +559,10 @@
},
{
"minmax": [
105,
101,
null
],
"types": {
"Contract": {
"version": " u32",
"state": "ContractState",
"contractId": "u64",
"twinId": "u32",
"contractType": "ContractData",
"solutionProviderID": "Option<U64>"
}
}
},
{
"minmax": [
118,
null
],
"types": {
"Node": {
"version": "u32",
"id": "u32",
"farmId": "u32",
"twinId": "u32",
"resources": "Resources",
"location": "Location",
"country": "Vec<u8>",
"city": "Vec<u8>",
"publicConfig": "Option<PublicConfig>",
"created": "u64",
"farmingPolicyId": "u32",
"interfaces": "Vec<Interface>",
"certification": "NodeCertification",
"secureBoot": "bool",
"virtualized": "bool",
"serialNumber": "Option<Vec<u8>>",
"connectionPrice": "u32"
},
"Location": {
"city": "Vec<u8>",
"country": "Vec<u8>",
"latitude": "Vec<u8>",
"longitude": "Vec<u8>"
}
}
},
{
"minmax": [
122,
null
],
"types": {
"ServiceContract": {
"serviceContractId": "u64",
"serviceTwinId:": "u32",
"consumerTwinId": "u32",
"baseFee": "u64",
"variableFee": "u64",
"metadata": "Vec<u8>",
"acceptedByService": "bool",
"acceptedByConsumer": "bool",
"lastBill": "u64",
"state": "ServiceContractState"
},
"ServiceContractState": {
"_enum": {
"Created": null,
"AgreementReady": null,
"ApprovedByBoth": null
}
},
"ServiceContractBill": {
"variableAmount": "u64",
"window": "u64",
"metadata": "Vec<u8>"
}
}
},
{
"minmax": [
124,
null
],
"types": {
"Twin": {
"id": "u32",
"accountId": "AccountId",
"relay": "Vec<u8>",
"entities": "Vec<EntityProof>",
"pk": "Vec<u8>"
}
}
},
{
"minmax": [
125,
null
],
"types": {
"NodePower": {
"state": "PowerState",
"target": "Power"
},
"PowerState": {
"_enum": {
"Up": null,
"Down": "BlockNumber"
}
},
"Power": {
"_enum": [
"Up",
"Down"
]
}
}
},
{
"minmax": [
147,
147
],
"types": {
"Cause": {
"_enum": [
"CanceledByCollective",
"CanceledByUser",
"OutOfFunds"
]
}
}
},
{
"minmax": [
148,
null
],
"types": {
"Cause": {
"_enum": [
"CanceledByUser",
"OutOfFunds",
"CanceledByCollective"
]
}
}
"types": {}
}
]
}
Expand Down
16 changes: 16 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,19 @@ type ServiceContractBill @entity {
metadata: String
amount: BigInt!
}

type PowerTargetReport @entity {
farmID: Int!
nodeID: Int!
newPowerTarget: Power!
block: Int!
timestamp: BigInt!
}

type PowerStateReport @entity {
farmID: Int!
nodeID: Int!
newPowerState: PowerState!
block: Int!
timestamp: BigInt!
}
Loading

0 comments on commit 9e8000a

Please sign in to comment.