Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commiteea20ff

Browse files
committed
Merge branch 'dmius-l003' into 'master'
fix: l003 sortSee merge request postgres-ai/postgres-checkup!451
2 parentse680614 +cb90246 commiteea20ff

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

‎pghrep/src/checkup/checkuputil.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,9 @@ func SortItemsByInt(data interface{}, field string, reverse bool) []string {
274274
// Get map keys sorted by defined float64 field inside struct
275275
funcSortItemsByFloat64(datainterface{},fieldstring,reversebool) []string {
276276
varresult []string
277-
varnumDatamap[float64]string=map[float64]string{}
277+
varnumDatamap[float64]int=map[float64]int{}
278278
varkeys []float64
279+
varvalues []string
279280

280281
v:=reflect.ValueOf(data)
281282

@@ -298,7 +299,16 @@ func SortItemsByFloat64(data interface{}, field string, reverse bool) []string {
298299

299300
num:=valNum.Interface()
300301
floatNum:=num.(float64)
301-
numData[floatNum]=id.(string)
302+
fortrue {
303+
if_,ok:=numData[floatNum];ok {
304+
floatNum=floatNum*1.000001
305+
}else {
306+
break
307+
}
308+
}
309+
310+
values=append(values,id.(string))
311+
numData[floatNum]=len(values)-1
302312
keys=append(keys,floatNum)
303313
}
304314

@@ -309,7 +319,7 @@ func SortItemsByFloat64(data interface{}, field string, reverse bool) []string {
309319
}
310320

311321
for_,key:=rangekeys {
312-
result=append(result,numData[key])
322+
result=append(result,values[numData[key]])
313323
}
314324
}
315325

‎pghrep/src/checkup/l003/l003.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77

88
checkup".."
9+
"../../pyraconv"
910
"github.com/dustin/go-humanize/english"
1011
)
1112

@@ -41,6 +42,18 @@ func L003Process(report L003Report) (checkup.ReportResult, error) {
4142
returnresult,nil
4243
}
4344

45+
funcL003ProcessSortTables(datamap[string]interface{},reportL003Report) (map[string]interface{},error) {
46+
forhost,hostData:=rangereport.Results {
47+
sortedTables:=checkup.SortItemsByFloat64(hostData.Data.Tables,"CapacityUsedPercent",true)
48+
results:=pyraconv.ToInterfaceMap(data["results"])
49+
rawHostData:=pyraconv.ToInterfaceMap(results[host])
50+
tablesData:=pyraconv.ToInterfaceMap(rawHostData["data"])
51+
tablesData["sortedTables"]=sortedTables
52+
}
53+
54+
returndata,nil
55+
}
56+
4457
funcL003PreprocessReportData(datamap[string]interface{}) {
4558
varreportL003Report
4659
filePath:=data["source_path_full"].(string)
@@ -56,5 +69,6 @@ func L003PreprocessReportData(data map[string]interface{}) {
5669
return
5770
}
5871

72+
data,_=L003ProcessSortTables(data,report)
5973
checkup.SaveReportResult(data,result)
6074
}

‎pghrep/templates/L003.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ Current database: {{ .database }}
88
{{-if (index (index .results .hosts.master)"data")}}
99
{{ifgt (Int (index (index (index .results .reorderedHosts.master)"data")"min_table_size_bytes")) 0}}NOTICE: only tables larger than{{ ByteFormat (index (index (index .results .reorderedHosts.master)"data")"min_table_size_bytes") 0}} are analyzed.
1010
{{end}}
11-
{{-if (index (index (index .results .hosts.master)"data")"tables")}}
11+
{{-if (index (index (index .results .hosts.master)"data")"sortedTables")}}
1212
### Master (`{{.hosts.master}}`) ###
1313
{{ifge (len (index (index .results .hosts.master)"data")) .LISTLIMIT}}The list is limited to{{.LISTLIMIT}} items. Total:{{ Sub (len (index (index .results .hosts.master)"data")) 1}}.{{ end}}
1414

1515
| Table | PK | Type | Current max value |▼ Capacity used, % |
1616
|------|----|------|-------------------|-------------------------------|
17-
{{ range$i,$key := (index (index (index(index.results .hosts.master)"data")"tables")"_keys")}}
17+
{{ range$i,$table := (index (index (index .results .hosts.master)"data")"sortedTables")}}
1818
{{-iflt$i $.LISTLIMIT -}}
19-
{{-$value := (index (index (index (index $.results $.hosts.master)"data")"tables")$key) -}}
19+
{{-$value := (index (index (index (index $.results $.hosts.master)"data")"tables")$table) -}}
2020
|`{{ index$value"table"}}` | `{{ index$value"pk"}}` |{{ index$value"type"}} |{{- RawIntFormat (index$value"current_max_value")}} |{{ index$value"capacity_used_percent"}}|
21-
{{ end}}
2221
{{- end}}
22+
{{ end}}
2323
{{-else -}}{{/*Tables data*/}}
2424
Nothing found
2525
{{- end}}{{/*Tables data*/}}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp