about summary refs log tree commit diff stats
path: root/internal/components/data.go
diff options
context:
space:
mode:
authorAlan Pearce2025-03-19 20:49:46 +0100
committerAlan Pearce2025-03-19 20:51:40 +0100
commit383ee780613116e78db9114a39a2d6127533463c (patch)
treec07e2af7ae910d5c6f80836dce8457ba44c54ceb /internal/components/data.go
parent49e3004d33bf84aa081460e4a6d89a8d84cc12b0 (diff)
downloadsearchix-383ee780613116e78db9114a39a2d6127533463c.tar.lz
searchix-383ee780613116e78db9114a39a2d6127533463c.tar.zst
searchix-383ee780613116e78db9114a39a2d6127533463c.zip
feat: show last/next/current indexing run time
Diffstat (limited to 'internal/components/data.go')
-rw-r--r--internal/components/data.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/components/data.go b/internal/components/data.go
index 977b90e..9bc0c5e 100644
--- a/internal/components/data.go
+++ b/internal/components/data.go
@@ -1,12 +1,21 @@
 package components
 
 import (
+	"time"
+
 	"go.alanpearce.eu/searchix/frontend"
 	"go.alanpearce.eu/searchix/internal/config"
 	search "go.alanpearce.eu/searchix/internal/index"
 	"go.alanpearce.eu/searchix/internal/nix"
 )
 
+var Indexing struct {
+	InProgress bool
+	StartedAt  time.Time
+	FinishedAt time.Time
+	NextRun    time.Time
+}
+
 type TemplateData struct {
 	Sources       []*config.Source
 	Source        *config.Source
@@ -34,3 +43,22 @@ func convertMatch[I nix.Importable](m nix.Importable) *I {
 
 	return &i
 }
+
+func SetNextRun(nextRun time.Time) {
+	Indexing.NextRun = nextRun
+}
+
+func SetLastUpdated(last time.Time) {
+	Indexing.FinishedAt = last
+}
+
+func MarkIndexingStarted() {
+	Indexing.StartedAt = time.Now()
+	Indexing.InProgress = true
+}
+
+func MarkIndexingFinished(nextRun time.Time) {
+	Indexing.FinishedAt = time.Now()
+	Indexing.InProgress = false
+	Indexing.NextRun = nextRun
+}