Skip to content

Commit

Permalink
MB-33748 Making time in catalogs ISO-8601 format
Browse files Browse the repository at this point in the history
Change-Id: I0707cecd175b81efa6c46e677987c7a6071ffe32
Reviewed-on: https://review.couchbase.org/c/query/+/178963
Reviewed-by: Donald Haggart <donald.haggart@couchbase.com>
Tested-by: Allu Baba Sai Harsha <allu.harsha@couchbase.com>
  • Loading branch information
allu-harsha committed Aug 24, 2022
1 parent 73e10fe commit 174adf1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion datastore/system/system_keyspace_functions_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/couchbase/query/functions"
"github.com/couchbase/query/timestamp"
"github.com/couchbase/query/value"
"github.com/couchbase/query/util"
)

type functionsCacheKeyspace struct {
Expand Down Expand Up @@ -105,7 +106,7 @@ func (b *functionsCacheKeyspace) Fetch(keys []string, keysMap map[string]value.A

// only give times for entries that have completed at least one execution
if entry.Uses > 0 && entry.ServiceTime > 0 {
itemMap["lastUse"] = entry.LastUse.String()
itemMap["lastUse"] = entry.LastUse.Format(util.DEFAULT_FORMAT)
itemMap["avgServiceTime"] = (time.Duration(entry.ServiceTime) /
time.Duration(entry.Uses)).String()
itemMap["minServiceTime"] = time.Duration(entry.MinServiceTime).String()
Expand Down
3 changes: 2 additions & 1 deletion datastore/system/system_keyspace_prepareds.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/couchbase/query/prepareds"
"github.com/couchbase/query/timestamp"
"github.com/couchbase/query/value"
"github.com/couchbase/query/util"
)

type preparedsKeyspace struct {
Expand Down Expand Up @@ -128,7 +129,7 @@ func (b *preparedsKeyspace) Fetch(keys []string, keysMap map[string]value.Annota

// only give times for entries that have completed at least one execution
if entry.Uses > 0 && entry.RequestTime > 0 {
itemMap["lastUse"] = entry.LastUse.String()
itemMap["lastUse"] = entry.LastUse.Format(util.DEFAULT_FORMAT)
itemMap["avgElapsedTime"] = (time.Duration(entry.RequestTime) /
time.Duration(entry.Uses)).String()
itemMap["avgServiceTime"] = (time.Duration(entry.ServiceTime) /
Expand Down
7 changes: 4 additions & 3 deletions datastore/system/system_keyspace_tasks_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/couchbase/query/scheduler"
"github.com/couchbase/query/timestamp"
"github.com/couchbase/query/value"
"github.com/couchbase/query/util"
)

type tasksCacheKeyspace struct {
Expand Down Expand Up @@ -97,7 +98,7 @@ func (b *tasksCacheKeyspace) Fetch(keys []string, keysMap map[string]value.Annot
"name": entry.Name,
"id": entry.Id,
"state": entry.State,
"submitTime": entry.PostTime.String(),
"submitTime": entry.PostTime.Format(util.DEFAULT_FORMAT),
"delay": entry.Delay.String(),
}
if entry.Results != nil {
Expand All @@ -113,10 +114,10 @@ func (b *tasksCacheKeyspace) Fetch(keys []string, keysMap map[string]value.Annot
itemMap["errors"] = errors
}
if !entry.StartTime.IsZero() {
itemMap["startTime"] = entry.StartTime.String()
itemMap["startTime"] = entry.StartTime.Format(util.DEFAULT_FORMAT)
}
if !entry.EndTime.IsZero() {
itemMap["stopTime"] = entry.EndTime.String()
itemMap["stopTime"] = entry.EndTime.Format(util.DEFAULT_FORMAT)
}
if node != "" {
itemMap["node"] = node
Expand Down
21 changes: 11 additions & 10 deletions server/http/admin_accounting_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/couchbase/query/tenant"
"github.com/couchbase/query/transactions"
"github.com/couchbase/query/value"
"github.com/couchbase/query/util"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -511,7 +512,7 @@ func doPrepared(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request

// only give times for entries that have completed at least one execution
if entry.Uses > 0 && entry.RequestTime > 0 {
itemMap["lastUse"] = entry.LastUse.String()
itemMap["lastUse"] = entry.LastUse.Format(util.DEFAULT_FORMAT)
itemMap["avgElapsedTime"] = (time.Duration(entry.RequestTime) /
time.Duration(entry.Uses)).String()
itemMap["avgServiceTime"] = (time.Duration(entry.ServiceTime) /
Expand Down Expand Up @@ -567,7 +568,7 @@ func doPrepareds(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Reques
data[i]["statement"] = d.Prepared.Text()
data[i]["uses"] = d.Uses
if d.Uses > 0 {
data[i]["lastUse"] = d.LastUse.String()
data[i]["lastUse"] = d.LastUse.Format(util.DEFAULT_FORMAT)
}
i++
return true
Expand Down Expand Up @@ -618,7 +619,7 @@ func doFunction(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request

// only give times for entries that have completed at least one execution
if entry.Uses > 0 && entry.ServiceTime > 0 {
itemMap["lastUse"] = entry.LastUse.String()
itemMap["lastUse"] = entry.LastUse.Format(util.DEFAULT_FORMAT)
itemMap["avgServiceTime"] = (time.Duration(entry.ServiceTime) /
time.Duration(entry.Uses)).String()
itemMap["minServiceTime"] = time.Duration(entry.MinServiceTime).String()
Expand Down Expand Up @@ -656,7 +657,7 @@ func doFunctions(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Reques
d.Signature(data[i])
d.Body(data[i])
if d.Uses > 0 {
data[i]["lastUse"] = d.LastUse.String()
data[i]["lastUse"] = d.LastUse.Format(util.DEFAULT_FORMAT)
}
i++
return true
Expand Down Expand Up @@ -782,7 +783,7 @@ func doTask(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request, af
"name": entry.Name,
"id": entry.Id,
"state": entry.State,
"submitTime": entry.PostTime.String(),
"submitTime": entry.PostTime.Format(util.DEFAULT_FORMAT),
"delay": entry.Delay.String(),
}
if entry.Results != nil {
Expand All @@ -792,10 +793,10 @@ func doTask(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request, af
itemMap["errors"] = entry.Errors
}
if !entry.StartTime.IsZero() {
itemMap["startTime"] = entry.StartTime.String()
itemMap["startTime"] = entry.StartTime.Format(util.DEFAULT_FORMAT)
}
if !entry.EndTime.IsZero() {
itemMap["stopTime"] = entry.EndTime.String()
itemMap["stopTime"] = entry.EndTime.Format(util.DEFAULT_FORMAT)
}
res = itemMap
})
Expand Down Expand Up @@ -836,13 +837,13 @@ func doTasks(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request, a
if d.Errors != nil {
data[i]["errors"] = d.Errors
}
data[i]["submitTime"] = d.PostTime.String()
data[i]["submitTime"] = d.PostTime.Format(util.DEFAULT_FORMAT)
data[i]["delay"] = d.Delay.String()
if !d.StartTime.IsZero() {
data[i]["startTime"] = d.StartTime.String()
data[i]["startTime"] = d.StartTime.Format(util.DEFAULT_FORMAT)
}
if !d.EndTime.IsZero() {
data[i]["stopTime"] = d.EndTime.String()
data[i]["stopTime"] = d.EndTime.Format(util.DEFAULT_FORMAT)
}
i++
return true
Expand Down

0 comments on commit 174adf1

Please sign in to comment.