diff options
Diffstat (limited to 'internal/store/store.go')
| -rw-r--r-- | internal/store/store.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/store/store.go b/internal/store/store.go index 211162e..eb017db 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -185,6 +185,15 @@ func (s *Store) Insert(e *Entry) (int64, error) { return id, nil } +// Count returns the total number of history entries. +func (s *Store) Count() (int64, error) { + var n int64 + if err := s.db.QueryRow(`SELECT count(*) FROM history`).Scan(&n); err != nil { + return 0, fmt.Errorf("count history: %w", err) + } + return n, nil +} + // List returns up to limit history summaries older than beforeID (or the // most recent if beforeID is 0), newest first. func (s *Store) List(limit int, beforeID int64) ([]Summary, error) { |