mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-14 19:21:46 +03:00
Fix activity list
This commit is contained in:
parent
77770112bd
commit
56f3b45a4e
@ -154,7 +154,7 @@ func (client *Client) setServerVersion() {
|
||||
// Detect cockroachdb
|
||||
matches = cockroachSignature.FindAllStringSubmatch(version, 1)
|
||||
if len(matches) > 0 {
|
||||
client.serverType = postgresType
|
||||
client.serverType = cockroachType
|
||||
client.serverVersion = matches[0][1]
|
||||
return
|
||||
}
|
||||
@ -255,9 +255,11 @@ func (client *Client) TableConstraints(table string) (*Result, error) {
|
||||
|
||||
// Returns all active queriers on the server
|
||||
func (client *Client) Activity() (*Result, error) {
|
||||
chunks := strings.Split(client.serverVersion, ".")
|
||||
version := strings.Join(chunks[0:2], ".")
|
||||
if client.serverType == cockroachType {
|
||||
return client.query("SHOW QUERIES")
|
||||
}
|
||||
|
||||
version := getMajorMinorVersion(client.serverVersion)
|
||||
query := statements.Activity[version]
|
||||
if query == "" {
|
||||
query = statements.Activity["default"]
|
||||
|
15
pkg/client/util.go
Normal file
15
pkg/client/util.go
Normal file
@ -0,0 +1,15 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Get short version from the string
|
||||
// Example: 10.2.3.1 -> 10.2
|
||||
func getMajorMinorVersion(str string) string {
|
||||
chunks := strings.Split(str, ".")
|
||||
if len(chunks) == 0 {
|
||||
return str
|
||||
}
|
||||
return strings.Join(chunks[0:2], ".")
|
||||
}
|
Loading…
Reference in New Issue
Block a user