github.com/altipla-consulting/ravendb-go-client@v0.1.3/query_statistics.go (about)

     1  package ravendb
     2  
     3  import "time"
     4  
     5  // TODO: is time.Time here our *Time?
     6  // TODO: needs json annotations?
     7  type QueryStatistics struct {
     8  	IsStale           bool
     9  	DurationInMs      int64
    10  	TotalResults      int
    11  	SkippedResults    int
    12  	Timestamp         time.Time
    13  	IndexName         string
    14  	IndexTimestamp    time.Time
    15  	LastQueryTime     time.Time
    16  	TimingsInMs       map[string]float64
    17  	ResultEtag        int64 // TODO: *int64 ?
    18  	ResultSize        int64
    19  	ScoreExplanations map[string]string
    20  }
    21  
    22  func NewQueryStatistics() *QueryStatistics {
    23  	return &QueryStatistics{
    24  		TimingsInMs: make(map[string]float64),
    25  	}
    26  }
    27  
    28  func (s *QueryStatistics) UpdateQueryStats(qr *QueryResult) {
    29  	s.IsStale = qr.IsStale
    30  	s.DurationInMs = qr.DurationInMs
    31  	s.TotalResults = qr.TotalResults
    32  	s.SkippedResults = qr.SkippedResults
    33  	s.Timestamp = qr.IndexTimestamp.toTime()
    34  	s.IndexName = qr.IndexName
    35  	s.IndexTimestamp = qr.IndexTimestamp.toTime()
    36  	s.TimingsInMs = qr.TimingsInMs
    37  	s.LastQueryTime = qr.LastQueryTime.toTime()
    38  	s.ResultSize = qr.ResultSize
    39  	s.ResultEtag = qr.ResultEtag
    40  	s.ScoreExplanations = qr.ScoreExplanations
    41  }