summary refs log tree commit diff stats
path: root/registry/index.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-14 03:40:02 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-14 03:59:47 -0400
commitfaad3621aea68c05d67e86e3b1b3dfc983c7b620 (patch)
treecce34987043b5fdf793fcffc51a855d975e6693e /registry/index.go
parent1dcdbca485394818381549a98b7d4c809842526c (diff)
downloadgetwtxt-faad3621aea68c05d67e86e3b1b3dfc983c7b620.tar.gz
fleshing out Indexer interface
Diffstat (limited to 'registry/index.go')
-rw-r--r--registry/index.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/registry/index.go b/registry/index.go
index c3ea178..c5f8d2c 100644
--- a/registry/index.go
+++ b/registry/index.go
@@ -5,11 +5,6 @@ import (
 	"time"
 )
 
-// NewUserIndex returns a new instance of a user index
-func NewUserIndex() *UserIndex {
-	return &UserIndex{}
-}
-
 // AddUser inserts a new user into the index. The *Data struct
 // contains the nickname and the time the user was added.
 func (index UserIndex) AddUser(nick string, url string) {
@@ -28,3 +23,24 @@ func (index UserIndex) DelUser(url string) {
 	delete(index, url)
 	imutex.Unlock()
 }
+
+// GetUserStatuses returns a TimeMap containing a user's statuses
+func (index UserIndex) GetUserStatuses(url string) TimeMap {
+	imutex.RLock()
+	status := index[url].Status
+	imutex.RUnlock()
+	return status
+}
+
+// GetStatuses returns a TimeMap containing all statuses
+func (index UserIndex) GetStatuses() TimeMap {
+	statuses := NewTimeMap()
+	imutex.RLock()
+	for _, v := range index {
+		for a, b := range v.Status {
+			statuses[a] = b
+		}
+	}
+	imutex.RUnlock()
+	return statuses
+}