diff --git a/db/bookmarks.go b/db/bookmarks.go index a29ec70..ece7301 100644 --- a/db/bookmarks.go +++ b/db/bookmarks.go @@ -280,3 +280,12 @@ func (m *BookmarkManager) UpdateContent() { time.Sleep(time.Second * 5) } } + +func (m *BookmarkManager) Stats() (entity.DBStats, error) { + stats := entity.DBStats{} + err := m.db.store.Get("stats", &stats) + if err != nil && err != bolthold.ErrNotFound { + return stats, fmt.Errorf("could not load stats: %s", err) + } + return stats, nil +} diff --git a/entity/meta.go b/entity/meta.go index ce4bd7c..6af91d2 100644 --- a/entity/meta.go +++ b/entity/meta.go @@ -32,3 +32,16 @@ func (stats DBStats) String() string { } return out } + +func (stats DBStats) MostRecentBookmarkInfo() BookmarkInfo { + mostRecent := time.Time{} + for k := range stats.History { + if k.After(mostRecent) { + mostRecent = k + } + } + if !mostRecent.IsZero() { + return stats.History[mostRecent] + } + return BookmarkInfo{} +} diff --git a/web/templates/_layout.html b/web/templates/_layout.html index 489d14a..22560c0 100644 --- a/web/templates/_layout.html +++ b/web/templates/_layout.html @@ -35,7 +35,7 @@
diff --git a/web/templates/info.html b/web/templates/info.html index 851ee33..d87cdd0 100644 --- a/web/templates/info.html +++ b/web/templates/info.html @@ -1,8 +1,12 @@{{ meminfo }}
+Memory in use | {{ meminfo }} |
---|---|
Bookmarks | {{ .stats.MostRecentBookmarkInfo.Bookmarks }} |
Words Indexed | {{ .stats.MostRecentBookmarkInfo.IndexedWords }} |