Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit 98dc65a

Browse files
committed
Keep rows order reworked, A006 template fixed
1 parent 88c458a commit 98dc65a

File tree

14 files changed

+481
-65
lines changed

14 files changed

+481
-65
lines changed

pghrep/src/main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"text/template"
2525
"sort"
2626
"strconv"
27+
"./orderedmap"
2728
)
2829

2930
var DEBUG bool = false
@@ -82,12 +83,13 @@ func FileExists(name string) bool {
8283
// Parse json data from string to map
8384
// Return map[string]interface{}
8485
func ParseJson(jsonData string) map[string]interface{} {
85-
var data map[string]interface{}
86-
if err := json.Unmarshal([]byte(jsonData), &data); err != nil {
86+
orderedData := orderedmap.New()
87+
if err := json.Unmarshal([]byte(jsonData), &orderedData); err != nil {
8788
dbg("Can't parse json data:", err)
8889
return nil
8990
} else {
90-
return data
91+
dt := orderedData.ToInterfaceArray()
92+
return dt
9193
}
9294
}
9395

@@ -239,8 +241,10 @@ func determineMasterReplica(data map[string]interface{}) {
239241
if hostData["role"] == "master" {
240242
hostRoles["master"] = host
241243
} else {
242-
index, _ := strconv.Atoi(pyraconv.ToString(hostData["index"]))
243-
replicas[index] = host
244+
if host != "_keys" {
245+
index, _ := strconv.Atoi(pyraconv.ToString(hostData["index"]))
246+
replicas[index] = host
247+
}
244248
}
245249
}
246250
var keys []int
@@ -292,7 +296,7 @@ func main() {
292296
} else {
293297
log.Fatal("ERROR: Content given by --checkdata is wrong json content.")
294298
}
295-
299+
296300
checkId = strings.ToUpper(checkId)
297301
loadDependencies(resultData)
298302
determineMasterReplica(resultData)

0 commit comments

Comments
 (0)