Skip to content

Commit 1f4d661

Browse files
authored
Merge pull request #1367 from threefoldtech/development_region_node
add region field in node response
2 parents b119605 + 2424527 commit 1f4d661

File tree

8 files changed

+15
-0
lines changed

8 files changed

+15
-0
lines changed

grid-proxy/docs/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grid-proxy/docs/swagger.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,9 @@
17941794
"country": {
17951795
"type": "string"
17961796
},
1797+
"region": {
1798+
"type": "string"
1799+
},
17971800
"latitude": {
17981801
"type": "number"
17991802
},

grid-proxy/docs/swagger.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ definitions:
121121
type: string
122122
country:
123123
type: string
124+
region:
125+
type: string
124126
latitude:
125127
type: number
126128
longitude:

grid-proxy/internal/explorer/converters.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func nodeFromDBNode(info db.Node) types.Node {
4343
City: info.City,
4444
Longitude: info.Longitude,
4545
Latitude: info.Latitude,
46+
Region: info.Continent,
4647
},
4748
PublicConfig: types.PublicConfig{
4849
Domain: info.Domain,
@@ -148,6 +149,7 @@ func nodeWithNestedCapacityFromDBNode(info db.Node) types.NodeWithNestedCapacity
148149
City: info.City,
149150
Longitude: info.Longitude,
150151
Latitude: info.Latitude,
152+
Region: info.Continent,
151153
},
152154
PublicConfig: types.PublicConfig{
153155
Domain: info.Domain,

grid-proxy/internal/explorer/db/postgres.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ func (d *PostgresDatabase) nodeTableQuery(ctx context.Context, filter types.Node
341341
"farm.name as farm_name",
342342
"node.twin_id",
343343
"node.country",
344+
"node_location.continent",
344345
"node.grid_version",
345346
"node.city",
346347
"node.uptime",

grid-proxy/internal/explorer/db/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type Node struct {
7474
Country string
7575
GridVersion int64
7676
City string
77+
Continent string
7778
Uptime int64
7879
Created int64
7980
FarmingPolicyID int64

grid-proxy/pkg/types/nodes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import "github.com/threefoldtech/zosbase/pkg/gridtypes"
66
type Location struct {
77
Country string `json:"country"`
88
City string `json:"city"`
9+
Region string `json:"region"`
910
Longitude *float64 `json:"longitude"`
1011
Latitude *float64 `json:"latitude"`
1112
}

grid-proxy/tests/queries/mock_client/nodes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func (g *GridProxyMockClient) Nodes(ctx context.Context, filter types.NodeFilter
154154
Location: types.Location{
155155
Country: node.Country,
156156
City: node.City,
157+
Region: g.data.Regions[node.Country],
157158
Longitude: g.data.Locations[node.LocationID].Longitude,
158159
Latitude: g.data.Locations[node.LocationID].Latitude,
159160
},
@@ -263,6 +264,7 @@ func (g *GridProxyMockClient) Node(ctx context.Context, nodeID uint32) (res type
263264
Location: types.Location{
264265
Country: node.Country,
265266
City: node.City,
267+
Region: g.data.Regions[node.Country],
266268
Longitude: g.data.Locations[node.LocationID].Longitude,
267269
Latitude: g.data.Locations[node.LocationID].Latitude,
268270
},

0 commit comments

Comments
 (0)