mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-15 03:36:33 +03:00
Merge pull request #265 from sosedoff/connection-usage
Record last query timestamp
This commit is contained in:
commit
206416889c
@ -5,6 +5,7 @@ import (
|
||||
neturl "net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
@ -20,6 +21,7 @@ type Client struct {
|
||||
db *sqlx.DB
|
||||
tunnel *Tunnel
|
||||
serverVersion string
|
||||
lastQueryTime time.Time
|
||||
History []history.Record `json:"history"`
|
||||
ConnectionString string `json:"connection_string"`
|
||||
}
|
||||
@ -265,6 +267,11 @@ func (client *Client) ServerVersion() string {
|
||||
}
|
||||
|
||||
func (client *Client) query(query string, args ...interface{}) (*Result, error) {
|
||||
// Update the last usage time
|
||||
defer func() {
|
||||
client.lastQueryTime = time.Now().UTC()
|
||||
}()
|
||||
|
||||
// We're going to force-set transaction mode on every query.
|
||||
// This is needed so that default mode could not be changed by user.
|
||||
if command.Opts.ReadOnly {
|
||||
|
Loading…
Reference in New Issue
Block a user