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 @@
-
Memory Usage
-

{{ meminfo }}

+
System information
+ + + + +
Memory in use{{ meminfo }}
Bookmarks{{ .stats.MostRecentBookmarkInfo.Bookmarks }}
Words Indexed{{ .stats.MostRecentBookmarkInfo.IndexedWords }}
Release info
{{ if not version.Remote.Valid }} diff --git a/web/web.go b/web/web.go index c5e1ecd..74a9566 100644 --- a/web/web.go +++ b/web/web.go @@ -396,8 +396,12 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server { ) }) - r.GET("/releaseinfo", func(c *gin.Context) { - meta := gin.H{"page": "releaseinfo", "config": config} + r.GET("/info", func(c *gin.Context) { + dbStats, err := bmm.Stats() + if err != nil { + panic("could not load stats for info page") + } + meta := gin.H{"page": "info", "stats": dbStats, "config": config} c.HTML(http.StatusOK, "_layout.html", meta, )