summary refs log tree commit diff stats
path: root/registry
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-14 03:19:26 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-14 03:19:26 -0400
commit1dcdbca485394818381549a98b7d4c809842526c (patch)
tree32b8f46cd8758d1b3fabcad69e57326c8d251b2a /registry
parent2492014051e5cd4c37287a09639d18f85e1349dc (diff)
downloadgetwtxt-1dcdbca485394818381549a98b7d4c809842526c.tar.gz
exported Data struct fields
Diffstat (limited to 'registry')
-rw-r--r--registry/index.go2
-rw-r--r--registry/query.go10
-rw-r--r--registry/types.go15
3 files changed, 15 insertions, 12 deletions
diff --git a/registry/index.go b/registry/index.go
index 4d82ebb..c3ea178 100644
--- a/registry/index.go
+++ b/registry/index.go
@@ -18,7 +18,7 @@ func (index UserIndex) AddUser(nick string, url string) {
 		log.Printf("Error formatting user add time as RFC3339: %v\n", err)
 	}
 	imutex.Lock()
-	index[url] = &Data{nick: nick, date: time.Now(), apidate: rfc3339date}
+	index[url] = &Data{Nick: nick, Date: time.Now(), APIdate: rfc3339date}
 	imutex.Unlock()
 }
 
diff --git a/registry/query.go b/registry/query.go
index e024bc6..32f5c6c 100644
--- a/registry/query.go
+++ b/registry/query.go
@@ -15,9 +15,9 @@ func (index UserIndex) QueryUser(name string) []string {
 	var users []string
 	imutex.RLock()
 	for k, v := range index {
-		if strings.Contains(v.nick, name) {
-			timekey[v.date] = v.nick + "\t" + k + "\t" + string(v.apidate)
-			keys = append(keys, v.date)
+		if strings.Contains(v.Nick, name) {
+			timekey[v.Date] = v.Nick + "\t" + k + "\t" + string(v.APIdate)
+			keys = append(keys, v.Date)
 		}
 	}
 	imutex.RUnlock()
@@ -48,7 +48,7 @@ func (index UserIndex) QueryTag(tag string) []string {
 // Returns the tweets with the tag as a []string.
 func (userdata *Data) FindTag(tag string) TimeMap {
 	var statuses TimeMap
-	for k, e := range userdata.status {
+	for k, e := range userdata.Status {
 		parts := strings.Split(e, "\t")
 		statusslice := strings.Split(parts[3], " ")
 		for _, v := range statusslice {
@@ -87,7 +87,7 @@ func (tm TimeMapSlice) SortByTime() []string {
 // GetStatuses returns the string slice containing a user's statuses
 func (index UserIndex) GetStatuses(url string) TimeMap {
 	imutex.RLock()
-	status := index[url].status
+	status := index[url].Status
 	imutex.RUnlock()
 	return status
 }
diff --git a/registry/types.go b/registry/types.go
index 43b323f..429c55c 100644
--- a/registry/types.go
+++ b/registry/types.go
@@ -14,19 +14,22 @@ type Indexer interface {
 // UserIndex provides an index of users by URL
 type UserIndex map[string]*Data
 
-// Data from user's twtxt.txt
+// Data on each user. `Nick` is the specified nickname. `Date` is the
+// time.Time of the user's submission to the registry. `APIdate` is the
+// RFC3339-formatted date/time of the user's submission. `Status` is a
+// TimeMap containing the user's statuses.
 type Data struct {
-	nick    string
-	date    time.Time
-	apidate []byte
-	status  TimeMap
+	Nick    string
+	Date    time.Time
+	APIdate []byte
+	Status  TimeMap
 }
 
 // TimeMap holds extracted and processed user data as a
 // string. A standard time.Time value is used as the key.
 type TimeMap map[time.Time]string
 
-// StatusMapSlice is a slice of StatusMaps. Useful for sorting the
+// TimeMapSlice is a slice of TimeMap. Useful for sorting the
 // output of queries.
 type TimeMapSlice []TimeMap