MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / GetHistory

Method GetHistory

internal/db/db.go:137–163  ·  view source on GitHub ↗

GetHistory returns the most recent n history entries.

(limit int)

Source from the content-addressed store, hash-verified

135
136// GetHistory returns the most recent n history entries.
137func (d *DB) GetHistory(limit int) ([]QueryHistory, error) {
138 rows, err := d.conn.Query(
139 `SELECT id, providers, regions, categories, product_families, attributes, prices, result_count, cache_key, created_at
140 FROM query_history ORDER BY created_at DESC LIMIT ?`, limit)
141 if err != nil {
142 return nil, err
143 }
144 defer rows.Close()
145
146 var result []QueryHistory
147 for rows.Next() {
148 var h QueryHistory
149 var createdStr string
150 err := rows.Scan(&h.ID, &h.Providers, &h.Regions, &h.Categories, &h.ProductFamilies,
151 &h.Attributes, &h.Prices, &h.ResultCount, &h.CacheKey, &createdStr)
152 if err != nil {
153 return nil, err
154 }
155 t, err := time.Parse(time.RFC3339, createdStr)
156 if err != nil {
157 t = time.Now()
158 }
159 h.CreatedAt = t
160 result = append(result, h)
161 }
162 return result, rows.Err()
163}
164
165// ClearAll deletes all history and pricing cache.
166func (d *DB) ClearAll() error {

Callers 5

UpdateMethod · 0.80
handleHistoryEventMethod · 0.80
switchViewNextMethod · 0.80
switchViewPrevMethod · 0.80
runHistoryFunction · 0.80

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected