forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery_statistics.go
41 lines (37 loc) · 1.07 KB
/
query_statistics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package ravendb
import "time"
// TODO: is time.Time here our *Time?
// TODO: needs json annotations?
type QueryStatistics struct {
IsStale bool
DurationInMs int64
TotalResults int
SkippedResults int
Timestamp time.Time
IndexName string
IndexTimestamp time.Time
LastQueryTime time.Time
TimingsInMs map[string]float64
ResultEtag int64 // TODO: *int64 ?
ResultSize int64
ScoreExplanations map[string]string
}
func NewQueryStatistics() *QueryStatistics {
return &QueryStatistics{
TimingsInMs: make(map[string]float64),
}
}
func (s *QueryStatistics) UpdateQueryStats(qr *QueryResult) {
s.IsStale = qr.IsStale
s.DurationInMs = qr.DurationInMs
s.TotalResults = qr.TotalResults
s.SkippedResults = qr.SkippedResults
s.Timestamp = qr.IndexTimestamp.toTime()
s.IndexName = qr.IndexName
s.IndexTimestamp = qr.IndexTimestamp.toTime()
s.TimingsInMs = qr.TimingsInMs
s.LastQueryTime = qr.LastQueryTime.toTime()
s.ResultSize = qr.ResultSize
s.ResultEtag = qr.ResultEtag
s.ScoreExplanations = qr.ScoreExplanations
}